473,549 Members | 2,723 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to re-enter a thread?

I'm using async delegate calls. I would like to re-enter my initial thread
after the callback. (I'm not using UI controls, so Control.Invoke is not the
solution.) How can I manually implement behavior like Control.Invoke? How
can I re-enter my initial thread? Any suggestions?
Thanks!
Mountain

I already searched Google Groups and found something on this topic, but no
solution:
http://groups.google.com/groups?hl=e...TNGP12.phx.gbl

Here's the most relevant prior post I found (again, no solution):
From: Lior Amar (li*******@hotm ail.com)
Subject: Re: Threads and Delegates
View: Complete Thread (18 articles)
Original Format
Newsgroups: microsoft.publi c.dotnet.langua ges.vb
Date: 2003-09-29 16:24:04 PST
Hey Peter,

Thanks for the links but these explain more on shared resources. Not really
having issues with multi-threading as is. More interested on making my
thread reentrant. Tried even overriding marshalling but nothing doing. Super
simple to thread in .NET but man is it tough to re-enter a thread. I know it
can be done with a Form/Component with the BeginInvoke. Tried that with
delegates but it doesn't do it. Did learn that if you try enough Async
delegate invokation that sooner or later the delegate call will be made on a
different thread also. Also found that you can make recursive
delegates....no t recommended though

Whatever approach I take, I can not get the call to reenter my initial
thread. I'm doing this with C++ and an ATL component but I would rather a
complete VB.NET solution.

Things I've tried so far:

1. Delegates
2. Shared Resources
3. Inheriting the RealProxy and Implementing the IRemotingTypeIn fo to try
and create a Single Threaded object using MarshalByRefObj ect.
4. ContextBoundObj ect
5. Sacrificing a small animal

Best results so far have been with #5

I've pretty much just gone with my C++ workaround but plan on working on it
more on my free time. It just seems like something that shouldn't be that
difficult!

Any ideas on what else I should try...Would love to know what the
Form/Component.Begin Invoke does to reenter it's thread

Thanks,

Lior
Nov 15 '05 #1
8 2380
Hi,

You can't.
Why would you even need to?
You'll have to syncronize your actions somehow (there are plenty of
synchronization mechanisms).
BTW, what kind of mounting bike do you have?
--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rhand.com

"Mountain Bikn' Guy" <vc@attbi.com > wrote in message
news:BiiHb.5495 2$VB2.96149@att bi_s51...
I'm using async delegate calls. I would like to re-enter my initial thread
after the callback. (I'm not using UI controls, so Control.Invoke is not the solution.) How can I manually implement behavior like Control.Invoke? How
can I re-enter my initial thread? Any suggestions?
Thanks!
Mountain

I already searched Google Groups and found something on this topic, but no
solution:
http://groups.google.com/groups?hl=e...TNGP12.phx.gbl
Here's the most relevant prior post I found (again, no solution):
From: Lior Amar (li*******@hotm ail.com)
Subject: Re: Threads and Delegates
View: Complete Thread (18 articles)
Original Format
Newsgroups: microsoft.publi c.dotnet.langua ges.vb
Date: 2003-09-29 16:24:04 PST
Hey Peter,

Thanks for the links but these explain more on shared resources. Not really having issues with multi-threading as is. More interested on making my
thread reentrant. Tried even overriding marshalling but nothing doing. Super simple to thread in .NET but man is it tough to re-enter a thread. I know it can be done with a Form/Component with the BeginInvoke. Tried that with
delegates but it doesn't do it. Did learn that if you try enough Async
delegate invokation that sooner or later the delegate call will be made on a different thread also. Also found that you can make recursive
delegates....no t recommended though

Whatever approach I take, I can not get the call to reenter my initial
thread. I'm doing this with C++ and an ATL component but I would rather a
complete VB.NET solution.

Things I've tried so far:

1. Delegates
2. Shared Resources
3. Inheriting the RealProxy and Implementing the IRemotingTypeIn fo to try
and create a Single Threaded object using MarshalByRefObj ect.
4. ContextBoundObj ect
5. Sacrificing a small animal

Best results so far have been with #5

I've pretty much just gone with my C++ workaround but plan on working on it more on my free time. It just seems like something that shouldn't be that
difficult!

Any ideas on what else I should try...Would love to know what the
Form/Component.Begin Invoke does to reenter it's thread

Thanks,

Lior

Nov 15 '05 #2

"Mountain Bikn' Guy" <vc@attbi.com > wrote in message
news:BiiHb.5495 2$VB2.96149@att bi_s51...
I'm using async delegate calls. I would like to re-enter my initial thread
after the callback. (I'm not using UI controls, so Control.Invoke is not the solution.) How can I manually implement behavior like Control.Invoke? How
can I re-enter my initial thread? Any suggestions?
Thanks!
Mountain


First off your main thread will have to be waiting. The delegate callback
will happen on a background thread. From the callback function you must
signal your main thread somehow, and probably pass it some data.

For instance you could use a Queue. Have your main thread lock the queue,
see if there is anyting on the queue (the callback may already be done!),
and then wait on its monitor. When the callback happens the delegate
function locks the queue, enqueues the state object and pulses the queue's
monitor, releasing the main thread. The main thread then deQueues the state
object and processes it.

I bet there's a slicker way to do it somehow, but using basic thread
syncronization mechanisms is good practice.

David

Nov 15 '05 #3
Ooooooooohhhh.
Lucky you :-)

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rhand.com

"Mountain Bikn' Guy" <vc@attbi.com > wrote in message
news:sjjHb.1508 47$8y1.441143@a ttbi_s52...
Cannondale Jekyll with Lefty fork.
http://www.cannondale.com/bikes/media/jekyll/
"Miha Markic" <miha at rthand com> wrote in message
news:eC******** ******@TK2MSFTN GP12.phx.gbl...
BTW, what kind of mounting bike do you have?
--


Nov 15 '05 #4
Not sure if this is what your looking for (You could be looking for
something else). but:

I am using events to communicate between threads. I have a communications
class that is polling on a back ground thread. In the Commucations class I
declaire something like:

Public Event Update_Status(B yVal Message_String As String)
In the Main module, i declaire something like:

AddHandler ClientComm.Upda te_Status, AddressOf Update_Status

Is this what your looking for? In the Comm module I just invoke the
Update_Status method to communicate to the main module that something
happened.

g.

"Mountain Bikn' Guy" <vc@attbi.com > wrote in message
news:BiiHb.5495 2$VB2.96149@att bi_s51...
I'm using async delegate calls. I would like to re-enter my initial thread
after the callback. (I'm not using UI controls, so Control.Invoke is not the solution.) How can I manually implement behavior like Control.Invoke? How
can I re-enter my initial thread? Any suggestions?
Thanks!
Mountain

I already searched Google Groups and found something on this topic, but no
solution:
http://groups.google.com/groups?hl=e...TNGP12.phx.gbl
Here's the most relevant prior post I found (again, no solution):
From: Lior Amar (li*******@hotm ail.com)
Subject: Re: Threads and Delegates
View: Complete Thread (18 articles)
Original Format
Newsgroups: microsoft.publi c.dotnet.langua ges.vb
Date: 2003-09-29 16:24:04 PST
Hey Peter,

Thanks for the links but these explain more on shared resources. Not really having issues with multi-threading as is. More interested on making my
thread reentrant. Tried even overriding marshalling but nothing doing. Super simple to thread in .NET but man is it tough to re-enter a thread. I know it can be done with a Form/Component with the BeginInvoke. Tried that with
delegates but it doesn't do it. Did learn that if you try enough Async
delegate invokation that sooner or later the delegate call will be made on a different thread also. Also found that you can make recursive
delegates....no t recommended though

Whatever approach I take, I can not get the call to reenter my initial
thread. I'm doing this with C++ and an ATL component but I would rather a
complete VB.NET solution.

Things I've tried so far:

1. Delegates
2. Shared Resources
3. Inheriting the RealProxy and Implementing the IRemotingTypeIn fo to try
and create a Single Threaded object using MarshalByRefObj ect.
4. ContextBoundObj ect
5. Sacrificing a small animal

Best results so far have been with #5

I've pretty much just gone with my C++ workaround but plan on working on it more on my free time. It just seems like something that shouldn't be that
difficult!

Any ideas on what else I should try...Would love to know what the
Form/Component.Begin Invoke does to reenter it's thread

Thanks,

Lior

Nov 15 '05 #5
Do you ride? What kind of bike?

"Miha Markic" <miha at rthand com> wrote in message
news:O3******** ******@tk2msftn gp13.phx.gbl...
Ooooooooohhhh.
Lucky you :-)

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rhand.com

"Mountain Bikn' Guy" <vc@attbi.com > wrote in message
news:sjjHb.1508 47$8y1.441143@a ttbi_s52...
Cannondale Jekyll with Lefty fork.
http://www.cannondale.com/bikes/media/jekyll/
"Miha Markic" <miha at rthand com> wrote in message
news:eC******** ******@TK2MSFTN GP12.phx.gbl...
BTW, what kind of mounting bike do you have?
--



Nov 15 '05 #6
If I could read VB better, I might know if this was something like what I am
looking for ;)

Is this any different from normal C# events, because the normal use of
events doesn't do it.
"gregory_ma y" <None> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Not sure if this is what your looking for (You could be looking for
something else). but:

I am using events to communicate between threads. I have a communications
class that is polling on a back ground thread. In the Commucations class I declaire something like:

Public Event Update_Status(B yVal Message_String As String)
In the Main module, i declaire something like:

AddHandler ClientComm.Upda te_Status, AddressOf Update_Status

Is this what your looking for? In the Comm module I just invoke the
Update_Status method to communicate to the main module that something
happened.

g.

"Mountain Bikn' Guy" <vc@attbi.com > wrote in message
news:BiiHb.5495 2$VB2.96149@att bi_s51...
I'm using async delegate calls. I would like to re-enter my initial thread after the callback. (I'm not using UI controls, so Control.Invoke is not

the
solution.) How can I manually implement behavior like Control.Invoke? How can I re-enter my initial thread? Any suggestions?
Thanks!
Mountain

I already searched Google Groups and found something on this topic, but no solution:

http://groups.google.com/groups?hl=e...TNGP12.phx.gbl

Nov 15 '05 #7
Hi David,
Thanks for your reply, but that's not what I was looking for (unless I am
missing your point). I was hoping the C# group would know something the VB
group didn't. The conversation at this link pretty much sums up what I'm
looking for:
http://groups.google.com/groups?hl=e...TNGP12.phx.gbl

The guy who made the original post didn't find a satisfactory VB.NET
solution and it seems like C# won't be any better.
Regards,
Mountain
"David Browne" <davidbaxterbro wne no potted me**@hotmail.co m> wrote in
message news:Ol******** ********@TK2MSF TNGP09.phx.gbl. ..

"Mountain Bikn' Guy" <vc@attbi.com > wrote in message
news:BiiHb.5495 2$VB2.96149@att bi_s51...
I'm using async delegate calls. I would like to re-enter my initial thread after the callback. (I'm not using UI controls, so Control.Invoke is not the
solution.) How can I manually implement behavior like Control.Invoke? How can I re-enter my initial thread? Any suggestions?
Thanks!
Mountain


First off your main thread will have to be waiting. The delegate callback
will happen on a background thread. From the callback function you must
signal your main thread somehow, and probably pass it some data.

For instance you could use a Queue. Have your main thread lock the queue,
see if there is anyting on the queue (the callback may already be done!),
and then wait on its monitor. When the callback happens the delegate
function locks the queue, enqueues the state object and pulses the queue's
monitor, releasing the main thread. The main thread then deQueues the

state object and processes it.

I bet there's a slicker way to do it somehow, but using basic thread
syncronization mechanisms is good practice.

David

Nov 15 '05 #8
Hi,

Of course I do :)
I used to have Cannondale M700 10 years ago - when I've began.
Now I have Olympia D.R.H. mix between EVO R-2 and TEAM (full susp, skareb
front susp).
Olympia web site is under construction, so there are no pictures
http://www.olympiacicli.it/prodotti.htm
e-mail me (is your e-mail address real?) so I can send you a pic of the bike
:) and we don't clutter the thread

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rhand.com

"Mountain Bikn' Guy" <vc@attbi.com > wrote in message
news:4YqHb.4974 70$275.1402605@ attbi_s53...
Do you ride? What kind of bike?

"Miha Markic" <miha at rthand com> wrote in message
news:O3******** ******@tk2msftn gp13.phx.gbl...
Ooooooooohhhh.
Lucky you :-)

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rhand.com

"Mountain Bikn' Guy" <vc@attbi.com > wrote in message
news:sjjHb.1508 47$8y1.441143@a ttbi_s52...
Cannondale Jekyll with Lefty fork.
http://www.cannondale.com/bikes/media/jekyll/
"Miha Markic" <miha at rthand com> wrote in message
news:eC******** ******@TK2MSFTN GP12.phx.gbl...
> BTW, what kind of mounting bike do you have?
> --



Nov 15 '05 #9

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

Similar topics

1
4274
by: Nel | last post by:
I have a question related to the "security" issues posed by Globals ON. It is good programming technique IMO to initialise variables, even if it's just $foo = 0; $bar = ""; Surely it would be better to promote better programming than rely on PHP to compensate for lazy programming?
4
6413
by: Craig Bailey | last post by:
Anyone recommend a good script editor for Mac OS X? Just finished a 4-day PHP class in front of a Windows machine, and liked the editor we used. Don't recall the name, but it gave line numbers as well as some color coding, etc. Having trouble finding the same in an editor that'll run on OS X. -- Floydian Slip(tm) - "Broadcasting from...
1
4083
by: Chris | last post by:
Sorry to post so much code all at once but I'm banging my head against the wall trying to get this to work! Does anyone have any idea where I'm going wrong? Thanks in advance and sorry again for adding so much code... <TABLE border="1" bordercolor="#000000" cellspacing="0"> <TR>
4
18519
by: Alan Walkington | last post by:
Folks: How can I get an /exec'ed/ process to run in the background on an XP box? I have a monitor-like process which I am starting as 'exec("something.exe");' and, of course the exec function blocks until something.exe terminates. Just what I /don't/ want. (Wouldn't an & be nice here! Sigh) I need something.exe to disconnect and...
1
3689
by: John Ryan | last post by:
What PHP code would I use to check if submitted sites to my directory actually exist?? I want to use something that can return the server code to me, ie HTTP 300 OK, or whatever. Can I do this with sockets??
10
4198
by: James | last post by:
What is the best method for creating a Web Page that uses both PHP and HTML ? <HTML> BLA BLA BLA BLA BLA
8
4400
by: Beowulf | last post by:
Hi Guru's, I have a query regarding using PHP to maintain a user profiles list. I want to be able to have a form where users can fill in their profile info (Name, hobbies etc) and attach an image, which will upload the record to a mySql db so users can then either view all profiles or query.. I.e. show all males in UK, all femails over 35...
8
3647
by: Lothar Scholz | last post by:
Because PHP5 does not include the mysql extension any more is there a chance that we will see more Providers offering webspace with Firebird or Postgres Databases ? What is your opinion ? I must say that i like it to see mysql replaced by a real database (stored procedures etc.)
1
3626
by: joost | last post by:
Hello, I'm kind of new to mySQL but more used to Sybase/PHP What is illegal about this query or can i not use combined query's in mySQL? DELETE FROM manufacturers WHERE manufacturers_id NOT IN ( SELECT manufacturers_id FROM products )
3
3469
by: presspley | last post by:
I have bought the book on advanced dreamweaver and PHP recently. I have installed MySQL and PHP server but am getting an error on the $GET statement show below. It says there is a problem with the variable $GET but $GET is not a variable, I thought it came from the page that calls the PHP file? if(($_GET)==""){ this gets an error
0
7520
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7720
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7957
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7809
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3500
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1941
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1059
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.