473,327 Members | 1,976 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

.Invoke for my own objects

I tried in the vb group, but no answer. Maybe c# folks can help.

The controls and forms allow you to call their .Invoke method, which
allows you to switch back and process whatever you are processing on the
UI thread.
I'd like to implement .Invoke for my own objects for this type of
scenario below. Is it possible?
|

public class XXX
{
private YYY ObjectThatRunsOnDifferentThread = new YYY();
private delegate void myDelegate(string s);

//handles an event from ||ObjectThatRunsOnDifferentThread object|
| private void SomeEventHandler()
{
this.Invoke(new myDelegate(new ||myDelegate||(ProcessData)), new
object[] {"Data"});
}

private void ProcessData(string s)
{
}
}
|
Nov 16 '05 #1
1 1154
Frank Rizzo <no**@none.com> wrote:
I tried in the vb group, but no answer. Maybe c# folks can help.

The controls and forms allow you to call their .Invoke method, which
allows you to switch back and process whatever you are processing on the
UI thread.
I'd like to implement .Invoke for my own objects for this type of
scenario below. Is it possible?
|

public class XXX
{
private YYY ObjectThatRunsOnDifferentThread = new YYY();
private delegate void myDelegate(string s);

//handles an event from ||ObjectThatRunsOnDifferentThread object|
| private void SomeEventHandler()
{
this.Invoke(new myDelegate(new ||myDelegate||(ProcessData)), new
object[] {"Data"});
}

private void ProcessData(string s)
{
}
}


Assuming your "main" thread isn't a UI thread (if it is, just forward
the call to Control.Invoke), you need to write some kind of message
pump.

The code at http://www.yoda.arachsys.com/csharp/...eadlocks.shtml
may help you - the ConsumerJob method is basically the message pump
loop. (Except you'd put a delegate into the queue and then execute it.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Neil Fedin via .NET 247 | last post by:
I am writing a testing application that uses reflection to open assemblies and call methods. I have a function that looks like this... public void Method1 (int IDArray, bool SomethingElse){...
1
by: Eshrath Ali Khan | last post by:
Hi, I have a requirement where I am creating table object with different ids using XSL by taking an XML as input. The no of objects (tables) is not fixed. I want to write a javascript to invoke...
1
by: boxim | last post by:
hi all, I'm having a few problems whereby my application is hanging when using the Invoke method of a form's control. Basically, when a user clicks a button on the form, it calls a remote...
0
by: Paul Tomlinson | last post by:
Morning all. Let me describe my problem. Main thread creates child objects and threads and starts them Timer on the main thread (which only gets activated after the child threads have started)...
1
by: Chuck | last post by:
I am creating a pub/sub broker implementation in C# and I am having some trouble understanding how I should best implement the invoke portion in order to make sure it is as thread-safe as it can...
14
by: stic | last post by:
Hi, I'm in a middle of writing something like 'exception handler wraper' for a set of different methodes. The case is that I have ca. 40 methods form web servicem, with different return values...
0
by: Frank Rizzo | last post by:
The controls and forms allow you to call their .Invoke method, which allows you to switch back and process whatever you are processing on the UI thread. I'd like to implement .Invoke for my own...
15
by: Oleg Subachev | last post by:
I need to programmatically invoke from other class Click event of the Button on my Form. Button.OnClick method is protected, not public. How to perform this ? Oleg Subachev
1
by: ian | last post by:
Hi, I can't find a solution to this, so I've brought it to the experts. Using reflection I can get a MethodInfo object pointing at an assembly's method. Where I have a MethodInfo object...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.