asynchronous programming in .net

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ...

    #1

    asynchronous programming in .net

    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.
  • Cor

    #2
    Re: asynchronous programming in .net

    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

    [color=blue]
    > Does anyone know a good tutorial on asynchronous programming in .net?
    >
    > AsyncCallback And IASyncResult are driving me crazy. And the msdn[/color]
    documentation is not really helpful on this topic.[color=blue]
    >
    > I appreciate any recommendation.[/color]


    Comment

    • Paul Kimmel

      #3
      asynchronous programming in .net

      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
      [color=blue]
      >-----Original Message-----
      >Does anyone know a good tutorial on asynchronous[/color]
      programming in .net?[color=blue]
      >
      >AsyncCallbac k And IASyncResult are driving me crazy. And[/color]
      the msdn documentation is not really helpful on this topic.[color=blue]
      >
      >I appreciate any recommendation.
      >.
      >[/color]

      Comment

      • Trev Hunter

        #4
        Re: asynchronous programming in .net

        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.Be ginInvoke(nothi ng, nothing)

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

        ' Pause until the processing has finished
        DoStuffAsync.En dInvoke(objResu lt)

        End Sub


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

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

        End Sub

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

        HTH,

        Trev.


        "..." <anonymous@disc ussions.microso ft.com> wrote in message
        news:5168448C-B28A-4A28-869C-176EF18B58AB@mi crosoft.com...[color=blue]
        > Does anyone know a good tutorial on asynchronous programming in .net?
        >
        > AsyncCallback And IASyncResult are driving me crazy. And the msdn[/color]
        documentation is not really helpful on this topic.[color=blue]
        >
        > I appreciate any recommendation.[/color]


        Comment

        • ...

          #5
          RE: asynchronous programming in .net

          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
          [color=blue]
          >-----Original Message----
          >Does anyone know a good tutorial on asynchronous[/color]
          programming in .net[color=blue][color=green]
          >>AsyncCallba ck And IASyncResult are driving me crazy. And[/color][/color]
          the msdn documentation is not really helpful on this topic[color=blue][color=green]
          >>I appreciate any recommendation[/color]
          >
          >[/color]

          Comment

          • Trev Hunter

            #6
            Re: asynchronous programming in .net

            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.Be ginInvoke("test ", nothing, nothing)

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

            ' Pause until the processing has finished
            DoStuffAsync.En dInvoke(objResu lt)

            End Sub


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

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

            End Sub

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

            HTH,

            Trev.


            Comment

            • Michael Bray

              #7
              Re: asynchronous programming in .net

              =?Utf-8?B?Li4u?= <anonymous@disc ussions.microso ft.com> wrote in
              news:86725122-343B-4E87-9681-41E3A4189527@mi crosoft.com:
              [color=blue]
              > 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.[/color]

              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

              Comment

              Working...