Groups | Blog | Home
all groups > dotnet remoting > may 2005 >

dotnet remoting : Using GUI from .NET Remoting events



Willy Denoyette [MVP]
5/6/2005 12:00:00 AM

[quoted text, click to view]

You are confusing a number of things here.
1. Remoting as nothing to do with COM and Apartments (COM context
boundaries).
2.MTA and STA's have nothing to do with Control.Invoke. Control.Invoke is a
must when you need to touch the UI from another thread than the UI thread.

Simply in your case you have a UI thread that runs in an STA, that's needed
for COM interop with COM based UI elements. When you have another thread
(MTA/STA no matter what) that sinks remoting events, and you need to update
the UI from that thread, you have to marshal the call using Invoke or
BeginInvoke, point.

Willy.




david.blackhole NO[at]SPAM gmail.com
5/6/2005 11:01:42 AM
I have a server with .NET Remoting object, which has significant
number of events. I want to use these events from my client GUI
application. When an event is passed to the client application, it is
running under MTA (Multithread Apartment) and I have to use
Control.Invoke() to marshal it to STA (Singlethread Apartment).

Is there an other way to do this? Can I customize the .NET Remoting to
ensure that events are run under STA?


Thank you very much,

david.blackhole NO[at]SPAM gmail.com
5/6/2005 4:39:49 PM
I am very sorry; I tried to make the post short and I over-simplified
it. Plus, this is my first post to newsgroups.

Ok, the call must be marshaled using Invoke. My question is: Do I have
to call the Invoke in every event handler that accesses UI or can I
move the call to .NET Remoting by tweaking something?
AddThis Social Bookmark Button