Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

Winforms Threading

I'm using Winforms in a multi-threaded app. I'm having to make lots of updates to a form, and it turns out that marshalling the update calls is currently my bottleneck. I know I could batch all the updates and marshall once, but that would have an adverse effect on the UI thread.

What I'm wondering is if anyone has tried using mutexes to protect forms when accessing them from other threads. I can't find any documentation that says this will work. Has anyone tried this approach?

Michael Davidson
Monday, January 6, 2003

Search MSDN for "Multithreaded Windows Forms Control Sample"

WinForms require that all access to control properties be done from the main (UI) thread.  The sample shows how to use async invoke to update a listbox from another thread.  .Net does the inter-thread marshalling; once your delegate is called in the main thread, batching would be easy to do.

Monday, January 6, 2003

*  Recent Topics

*  Fog Creek Home