Hello Bob,
Thanks for your post. As I understand, you have some problems in a
multi-threaded WinForm application and want to locate them. Now I'd like to
share the following information with you:
1. Please make sure that you did not a control's method directly from
another thread. As you know, Windows Forms uses the single-threaded
apartment (STA) model because Windows Forms is based on native Win32
windows that are inherently apartment-threaded. The STA model implies that
a window can be created on any thread, but it cannot switch threads once
created, and all function calls to it must occur on its creation thread.
There are four methods on a control that are safe to call from any thread:
Invoke, BeginInvoke, EndInvoke, and CreateGraphics. For all other method
calls, you should use one of the invoke methods to marshal the call to the
control's thread.
I believe the following articles are helpful:
Safe, Simple Multithreading in Windows Forms, Part 1
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/htm
l/winforms06112002.asp
Safe, Simple Multithreading in Windows Forms, Part 2
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/htm
l/winforms08162002.asp
2. Another common issue in multi-threaded program is to synchronize threads
for protecting the shared resource. You can use Tracing/Logging machanism
to locate the problem in multi-threaded applicaitons.
Multithreaded Programming with Visual Basic .NET
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechar
t/html/vbtchasyncprocvb.asp
Visual Basic .NET: Tracing, Logging, and Threading Made Easy with .NET
http://msdn.microsoft.com/msdnmag/issues/01/07/vbnet/default.aspx 3. Based on my experience, there is nothing special when debugging
multi-threaded application and I believe the Tracing/Logging machanism is
very helpful. The following KB article contains most information on .NET
Debugging:
INFO: Roadmap for Debugging in .NET Framework and Visual Studio .NET
http://support.microsoft.com/?id=308626 4. Generally speaking, VS .NET Debugger is enough for debugging user-mode
application. If you want to debug low level applications say, Windows
Device Driver, you will need other debuggers (for example WinDbg).
There is also no need to install Windows Symbols for debugging
multi-threaded WinForm application. The following KB article describes the
symbol files (PDB and DBG files) in detail:
INFO: PDB and DBG Files - What They Are and How They Work
http://support.microsoft.com/default.aspx?scid=kb;EN-US;121366 Please feel free to let me know if you have any problems or concerns.
Have a nice day!
Regards,
HuangTM
Microsoft Online Partner Support
MCSE/MCSD
Get Secure! --
www.microsoft.com/security This posting is provided "as is" with no warranties and confers no rights.