473,394 Members | 1,802 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,394 software developers and data experts.

Invoke the main thread

Hi

I am looking for a method that allows calling a method that will be executed
by the main application thread bu will be called from any thread that I
create manually.
(I think that technically it is similar to sending a message to the
program)

I tried the Invoke method but it seem to work from the calling thread

Thank you,
Shmuel Shulman
Nov 22 '05 #1
1 2635
You will want to have a delegate function or event handler in your main
application. The function will need to use MyBase.Invoke or .BeginInvoke,
telling the main application to execute the statement. The function you
invoke should be a seperate function. Here is an example of how your main
application should handle the delegate call from the seperate thread(s) -

Private Delegate Sub MyHandlerDelegate()
Private MyDelegate As MyHandlerDelegate = AddressOf _Handler
Private Sub Handler()
MyBase.Invoke(MyDelegate)
End Sub
Private Sub _Handler()
'THIS IS NOW EXECUTED BY THE MAIN THREAD
End Sub

Hope that helps,
Kevin M. Schreiner

"S Shulman" wrote:
Hi

I am looking for a method that allows calling a method that will be executed
by the main application thread bu will be called from any thread that I
create manually.
(I think that technically it is similar to sending a message to the
program)

I tried the Invoke method but it seem to work from the calling thread

Thank you,
Shmuel Shulman

Nov 22 '05 #2

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

Similar topics

10
by: Charles Law | last post by:
I have a user control created on the main thread. Let's say, for arguments sake, that it has a single property that maintains a private variable. If I want to set that property from a worker...
1
by: S Shulman | last post by:
Hi I am looking for a method that allows calling a method that will be executed by the main application thread bu will be called from any thread that I create manually. (I think that...
3
by: David Logan | last post by:
I have an application using sockets, and it uses the asynchronous method for receiving (and others, but receiving is the basic problem.) In short, I want: class someClass: Form {...
19
by: trint | last post by:
Ok, I start my thread job: Thread t = new Thread(new ThreadStart(invoicePrintingLongRunningCodeThread)); t.IsBackground = true; t.Start(); There are lots of calls to controls and many...
6
by: Peter Rilling | last post by:
Okay, I have the main thread which does all the work. This main thread spawns a worker thread that just periodically poles the environment looking for a certain condition. This second thread is...
4
by: Charles Law | last post by:
Hi guys. I have two threads: a main thread and a background thread. Lots of stuff happens in the background thread that means I have to update several (lots) of controls on a form. It is...
7
by: Jeff Stewart | last post by:
I need a thread to run a subroutine which updates my main form's progress bar. I've properly marshaled all UI updates to the main UI thread, and after the main thread starts the worker thread, it...
3
by: SatCom | last post by:
Hello, I had originally posted this in the winforms.controls discussion, forgive the double post, Here is where I need help... I have been porting some VB6 to VB2005 and here is the issue with...
23
by: Thomas Due | last post by:
Hi, I have a class which monitors a TCP socket. This will on occasion raise an event which can be handled by a GUI. Now, I am aware of the if(InvokeRequire) { EventHandler d = new...
0
by: Sebouh | last post by:
Hi guys. I was messing with Threading and stuff, and i have reached a point where i'm not sure what's causing the current behavior. Here's the code: Public Class Form1 Private Sub...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.