|
-
May 28th, 2008, 12:09 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] [2008] Calling a function from another thread
Hello,
I have a function which is a callback. Code sippet below.
However, as the OnIncomingCall() will be on a different thread, I don't think it can call the IncomingCallAlert(). With controls you can use a delegate and invoke the control.
Which is the best way to do the same with a function?
Many thanks for any advice,
Steve
Code:
private sub OnIncomingCall()
.
.
IncomingCallAlert()
.
Sub End
private sub IncomingCallAlert()
'Play sound
Sub End
Last edited by steve_rm; May 28th, 2008 at 12:14 AM.
steve
-
May 28th, 2008, 12:45 AM
#2
Re: [2008] Calling a function from another thread
You don't invoke a control. You use a control to invoke a delegate and you use the delegate to marshal a method call to the UI thread. The reason you need to do that is that you cannot access the handle of a control on a thread that doesn't own it. That's the only reason you need to do it. If you're not accessing controls then there's no need for you to do that. You can call any method you like on any thread you like. All members are available to all threads at all times. That's exactly why you need to synchronise multiple threads: because they can all access the same data.
In short, just call the method without regard for the thread it's executing on.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|