Thread Safe or not ...
-
Hello !! :confused: I've been programing in Visual Studio 2003 and now i change IDE to Visual Studio 2005 Beta 2 and of course .NET 2.0 Beta. I converted the project i was doing and i run it. It show lots of runtime errors of Thread Safe because it looks like Windows.Forms is no longer a Thread safe operation (why have they change this???? don't have a clue). How can i call these objects in another thread? i know it has something to do with "Delegate" or "control.Invoke" but i think this has change too. Please help me. :( thanks !! ;) Sorry for my English... Bruno Conde pharaoh
-
Hello !! :confused: I've been programing in Visual Studio 2003 and now i change IDE to Visual Studio 2005 Beta 2 and of course .NET 2.0 Beta. I converted the project i was doing and i run it. It show lots of runtime errors of Thread Safe because it looks like Windows.Forms is no longer a Thread safe operation (why have they change this???? don't have a clue). How can i call these objects in another thread? i know it has something to do with "Delegate" or "control.Invoke" but i think this has change too. Please help me. :( thanks !! ;) Sorry for my English... Bruno Conde pharaoh
The operations that you speak of were allow to be written in kind of a shortcut fashion in 2003, but shouldn't have been. You have to rewrite the code to follow the more strict threading rules of 2005. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
Hello !! :confused: I've been programing in Visual Studio 2003 and now i change IDE to Visual Studio 2005 Beta 2 and of course .NET 2.0 Beta. I converted the project i was doing and i run it. It show lots of runtime errors of Thread Safe because it looks like Windows.Forms is no longer a Thread safe operation (why have they change this???? don't have a clue). How can i call these objects in another thread? i know it has something to do with "Delegate" or "control.Invoke" but i think this has change too. Please help me. :( thanks !! ;) Sorry for my English... Bruno Conde pharaoh
This[^] might help. Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
Hello !! :confused: I've been programing in Visual Studio 2003 and now i change IDE to Visual Studio 2005 Beta 2 and of course .NET 2.0 Beta. I converted the project i was doing and i run it. It show lots of runtime errors of Thread Safe because it looks like Windows.Forms is no longer a Thread safe operation (why have they change this???? don't have a clue). How can i call these objects in another thread? i know it has something to do with "Delegate" or "control.Invoke" but i think this has change too. Please help me. :( thanks !! ;) Sorry for my English... Bruno Conde pharaoh
Windows Forms has NEVER been thread safe! In fact, Win32 common controls have never been thread safe. Even the new UI coming in Windows Vista is not thread safe. In .NET 1.1, the application would run ok for awhile, but you'd run into subtle bugs eventually. In .NET 2.0, a error is issued if you try to use Windows Forms controls from another thread. If you want to use a Windows Forms control from another thread, use the Control.Invoke and Control.BeginInvoke methods:
void CalledFromAnotherThread()
{
// Call textbox.Invalidate() method on the UI thread.
myTextBox.Invoke((ThreadStart)myTextBox.Invalidate);
}Tech, life, family, faith: Give me a visit. I'm currently blogging about: Cops & Robbers Judah Himango