• Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

.net Ipc Vs2005

ASB

Godlike
Thanks received
91
To make life easier for one my developers I am looking for a windows control which I can use for IPC to the UI thread.

All I want to do is pass an object from one thread and have an event fire in a UI thread. It's making my head hurt thinking how I can achieve this. Any suggestions ?

It's just a load easier for him to drop a control on his form and handle the events rather than have to worry about updating the UI from different threads.

Cheers.
 

Naturally he can do that, but it's a bit of a pain for him to do it - though he may well have to [though it will take a fair bit of explaining the techniques he's going to need to use]. I think http://msdn.microsoft.com/en-us/library/system.threading.synchronizationcontext.aspx might help, but I've got a fair bit of reading up to do.

I could write a control that exposes the methods I want my thread to call and this queues them and dequeues them on a (form) timer or similar.

Basically al I want to end up with is in my thread SomeObject.PostMessage(object) and then in his UI Event MessageReceived(someData as object).

It seems as though there should be some control available which will help me with this, but stuffed if I can find one....
 
Naturally he can do that, but it's a bit of a pain for him to do it - though he may well have to [though it will take a fair bit of explaining the techniques he's going to need to use]. I think http://msdn.microsoft.com/en-us/library/system.threading.synchronizationcontext.aspx might help, but I've got a fair bit of reading up to do.

I could write a control that exposes the methods I want my thread to call and this queues them and dequeues them on a (form) timer or similar.

Basically al I want to end up with is in my thread SomeObject.PostMessage(object) and then in his UI Event MessageReceived(someData as object).

It seems as though there should be some control available which will help me with this, but stuffed if I can find one....

From what you've said (and apologies if I've misunderstood) I still think Control.Invoke is what you want here - although you may wish to hide the implementation from your developer by wrapping the functionality in something more "friendly". Assuming I have understood correctly, Control.Invoke is provided for the exact scenario you describe.
 
Hmm, I think that should pretty much do it. I need to review it and wrap it all up in a class I provide. Only issue I have is trying to hide it from my new developer as much as possible.

That's what that does. Hides all the jiggery pokery from the UI and shifts the complexity to the "worker" classes.


Have a look in the comments as there is a Generics solution suggested that reduces the coding.
 
From what you've said (and apologies if I've misunderstood) I still think Control.Invoke is what you want here - although you may wish to hide the implementation from your developer by wrapping the functionality in something more "friendly". Assuming I have understood correctly, Control.Invoke is provided for the exact scenario you describe.

I agree in general. However the guy has only been on a quick introduction so it's all a bit confusing for him - hence the need to hide implementation details. On the other hand of course I don't want to have to do too much myself :wink
 
I agree in general. However the guy has only been on a quick introduction so it's all a bit confusing for him - hence the need to hide implementation details. On the other hand of course I don't want to have to do too much myself :wink

Amen to that :laugh Shouldn't take too much to hide the gory detail from him though, but good luck with whichever solution you decide upon.
 

Advertisers

Back
Top