PC Review


Reply
Thread Tools Rate Thread

Communication between a thread and a form.

 
 
Fabrice HOEPPE
Guest
Posts: n/a
 
      14th Jan 2004

Hi,

I want to fire C# events from a thread to a windows form.
One way to do it, it's to call BeginInvoke, Invoke,
EndInvoke methods of the windows form control from the
thread. However, this mechanism uses the serialization of
data from the thread to the form. We can read into the
msdn that this mechanism requires a lot of resources
system. I need to improve this mechanism for a real time
application which uses a low resource system and which
must be run fastest. I have worked with an another team
which have been developped this kind of application but in
Java. I was very surprised of its performance. In my case,
it is the only one point that I must improve if I want to
be much competitive than Java. Do you have any ideas to
improve the communication between a thread to a no thread-
safe windows form or an another way to communicate from a
thread to a form into a thread safe context?

Fabrice
 
Reply With Quote
 
 
 
 
Nick Wienholt
Guest
Posts: n/a
 
      15th Jan 2004
I'm not sure if the parameters for an intra-AppDomian call are serialized,
but assuming they are, you can avoid the hit by using global variable
instead of parameters - maybe pass an integer representing the index of
large parameters in a globally accessible collection. As long as the
objects that would normally be passed as parameters are thread-safe, you
won't have any problems with this approach.

Nick Wienholt, MVP
Maximizing .NET Performance
http://www.apress.com/book/bookDisplay.html?bID=217
Sydney Deep .NET User Group www.sdnug.org

"Fabrice HOEPPE" <(E-Mail Removed)> wrote in message
news:0b2201c3dae4$88bd4590$(E-Mail Removed)...
>
> Hi,
>
> I want to fire C# events from a thread to a windows form.
> One way to do it, it's to call BeginInvoke, Invoke,
> EndInvoke methods of the windows form control from the
> thread. However, this mechanism uses the serialization of
> data from the thread to the form. We can read into the
> msdn that this mechanism requires a lot of resources
> system. I need to improve this mechanism for a real time
> application which uses a low resource system and which
> must be run fastest. I have worked with an another team
> which have been developped this kind of application but in
> Java. I was very surprised of its performance. In my case,
> it is the only one point that I must improve if I want to
> be much competitive than Java. Do you have any ideas to
> improve the communication between a thread to a no thread-
> safe windows form or an another way to communicate from a
> thread to a form into a thread safe context?
>
> Fabrice



 
Reply With Quote
 
Nick Wienholt
Guest
Posts: n/a
 
      19th Jan 2004
The actual cost of getting onto the UI thread is reasonably fixed. The
thread model of Windows requires the marshalling in the method you include,
and there isn't a lot you can do to bypass it. Posting a custom message to
the windows form message loop is pretty cheap, and would be an option I'd
try.

Nick


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
thread communication Ronny Microsoft C# .NET 9 16th Oct 2008 10:46 PM
Thread communication Maurice Microsoft Dot NET 1 23rd Nov 2004 02:03 PM
communication in different thread? Jet Leung Microsoft C# .NET 1 30th Aug 2004 08:06 PM
Inter-thread communication to pass a job to another thread James Lavery Microsoft VB .NET 2 26th May 2004 10:45 AM
Shut down thread - thread closes form, form doesn't close because thread calls it etc... Robin Tucker Microsoft VB .NET 4 17th Oct 2003 12:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:49 PM.