|
-
Dec 1st, 2002, 04:41 PM
#1
Thread Starter
yay gay
callbacks
what are exactly callbacks? they are made(used) by delegates right?
i have an example of a thing that by what i heared is the function of a callback: i have a button that calls a new thread and when the new thread is finished the callback continues the code on the thead...is it? or no? lol
\m/  \m/
-
Dec 1st, 2002, 06:22 PM
#2
PowerPoster
A callback is basically an event.
-
Dec 1st, 2002, 06:57 PM
#3
Lively Member
callbacks are basically a function pointer (delegate) that you can pass in to another object either by adding it as an event handler for a certain event or just as a parameter of a method.
Anyway the other object can use this delegate to invoke (callback) the function in the first object.
It's really useful for a lot of cases but it gets really cool when you use it with remoting where you have a server object calling back a function in clients object (to update some info for the clients for example).
-
Dec 2nd, 2002, 06:42 AM
#4
Thread Starter
yay gay
hmm...tks by the replys..so a button can call another thread and when that thread is finished can continue the code on the own button through a callback?
any tuturials around there about callbacks?
\m/  \m/
-
Dec 2nd, 2002, 10:12 AM
#5
Lively Member
You can do that but I would really question why you want to do that.
From what you're saying, I take it you want to do something like this.....
Thread A (main thread) calls another thread (Thread B) passing in the delegate and then suspend itself (Thread A).
Thread B do some processing and then just before finishing it's proessing call back Thread A to resume processing.
Well you can definitely do that. But doesn't that defeats the purpose of multi threading entirely?
I mean with multi threading you want both processes to be running simultaneously more or less and autonomously.
What you are trying to do can be done entirely using normal way of calling methods
-
Dec 2nd, 2002, 04:34 PM
#6
Thread Starter
yay gay
well..i have a first thread that is the main thread...nowaday if i want that when i click a button it will have another function that will be called by thread B...after the thread B finishes it will call a event and in that event i will put the rest of the needed code...i think this would be a lot better if i wouldn't have make the damn event and put *almost* all the code on the button code
\m/  \m/
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
|