By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 838 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

asynchronous programming in .net

P: n/a
...
Does anyone know a good tutorial on asynchronous programming in .net

AsyncCallback And IASyncResult are driving me crazy. And the msdn documentation is not really helpful on this topic

I appreciate any recommendation.
Jul 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Cor
Hi Anonymous

Have a look for "remoting" on msdn, I think the first week you have enough
to do reading about async.

You can also download the vb. resource kit there are samples in it.

http://msdn.microsoft.com/vbasic/vbrkit/default.aspx

And if you have problems installing it

http://msdn.microsoft.com/vbasic/vbr...q/#installvdir
I hope this helps a little bit?

Cor

Does anyone know a good tutorial on asynchronous programming in .net?

AsyncCallback And IASyncResult are driving me crazy. And the msdn documentation is not really helpful on this topic.
I appreciate any recommendation.

Jul 21 '05 #2

P: n/a
If you want VB try Visual Basic .NET Power Coding, for C3
try Advanced C#, or sign up for the VB Today codeguru.com
newsletter. The VB Today columns should have a couple
examples.

The callback is a delegate/function pointer that does the
work, and the IAsyncResult is a waithandle (I think!?) for
blocking.

Paul
-----Original Message-----
Does anyone know a good tutorial on asynchronous programming in .net?
AsyncCallback And IASyncResult are driving me crazy. And the msdn documentation is not really helpful on this topic.
I appreciate any recommendation.
.

Jul 21 '05 #3

P: n/a
As Cor mentioned, you could use some of the samples in the Remoting
infrastructure, although multithreading and asynchronous programming don't
have to involve remoting - remoting is more or less the .net version of
DCOM.

Here's some links that may help you out with threads and asynchronous
programming.

http://msdn.microsoft.com/library/de...ingExample.asp

http://msdn.microsoft.com/msdnmag/is...t/default.aspx

http://msdn.microsoft.com/library/de...enersample.asp

I suggest you also look up topics relating to the "thread pool" and
asynchronous delegates.

Here's a quick example on how to call a method asynchronously in VB.net with
one parameter (there are more ways to do this, but this is just a simple
example)

-------------------------

' Delegate to call async
Private Delegate Sub DoStuffDelegate(Byval MyParam as String)

' Main Entry point
Private Sub Main()

' Local Variables
Dim DoStuffAsync as new DoStuffDelegate(AddressOf Me.DoStuff)
Dim objResult as IAsyncResult

' Start the async processing
objResult = DoStuffAsync.BeginInvoke(nothing, nothing)

' Do some stuff in this thread
Threading.Thread.Sleep(5000)

' Pause until the processing has finished
DoStuffAsync.EndInvoke(objResult)

End Sub
' Method that runs on a different thread
Private Sub DoStuff()

' Do stuff on a different thread
Threading.Thread.Sleep(10000)

End Sub

-------------------------

HTH,

Trev.
"..." <an*******@discussions.microsoft.com> wrote in message
news:51**********************************@microsof t.com...
Does anyone know a good tutorial on asynchronous programming in .net?

AsyncCallback And IASyncResult are driving me crazy. And the msdn documentation is not really helpful on this topic.
I appreciate any recommendation.

Jul 21 '05 #4

P: n/a
...
Ok, but, doesnt a normal delegate doesnt do the work in the same manner as a AsyncCallback delegate? What is the difference? Its not like the asynchronous delegate works indeed asynchronous to the parent program

----- Paul Kimmel wrote: ----
The callback is a delegate/function pointer that does the
work, and the IAsyncResult is a waithandle (I think!?) for
blocking

Pau
-----Original Message----
Does anyone know a good tutorial on asynchronous

programming in .net
AsyncCallback And IASyncResult are driving me crazy. And the msdn documentation is not really helpful on this topicI appreciate any recommendation


Jul 21 '05 #5

P: n/a
Sorry. Bug Fix.... (forgot the parameter!)

-------------------------

' Delegate to call async
Private Delegate Sub DoStuffDelegate(Byval MyParam as String)

' Main Entry point
Private Sub Main()

' Local Variables
Dim DoStuffAsync as new DoStuffDelegate(AddressOf Me.DoStuff)
Dim objResult as IAsyncResult

' Start the async processing
objResult = DoStuffAsync.BeginInvoke("test", nothing, nothing)

' Do some stuff in this thread
Threading.Thread.Sleep(5000)

' Pause until the processing has finished
DoStuffAsync.EndInvoke(objResult)

End Sub
' Method that runs on a different thread
Private Sub DoStuff(Byval Param as String)

' Do stuff on a different thread
Threading.Thread.Sleep(10000)

End Sub

-------------------------

HTH,

Trev.
Jul 21 '05 #6

P: n/a
=?Utf-8?B?Li4u?= <an*******@discussions.microsoft.com> wrote in
news:86**********************************@microsof t.com:
To be honest.. not really. My problem is, i dont see the advantage of
the AsyncCallback delegate over a normal delegate.. What is the
advantage? The only advantage that i can see, is the IAsyncResult
object, that has useful members.

Maybe i dont got it, can someone explain it to me? Asynchronous over
synchronous.


Just because a delegate is a delegate doesn't mean that it runs
asynchronously. Normal delegates have to complete their processing before
the call to invoke the delegate will return.

-mdb
Jul 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.