put in a asynchronous call with a callback

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

    put in a asynchronous call with a callback

    Hi!

    I've implemented many times an asynchronous call of a method with a call
    backfunction successfully.

    But to implement this with VB.NET is not so successfully. I can implement
    all events ProcessingEvent , CompletedEvent, etc.
    It works fine and copies all files in the background ...

    Bit to make it perfekt I want to implement a callback function wich will be
    used to do the final work, show the finished message and so on.

    With C# I can do that with a BeginInvoke() on the event object. Looks like

    callback = new AsyncCallback(C opyCompletion);
    DoCopy.BeginInv oke(this, args, callback, args);

    But it is not possible to use BeginInvoke in that way in C#.

    How can I do that?

    Thanks for your help

    Gerda
  • Phil G.

    #2
    Re: put in a asynchronous call with a callback

    Hi Gerda,

    Fortunately you are mistaken. VB.Net uses the same classes and methods. See
    my response to Brad Rogers, dated 13/9/05 (UK date :-) and titled Delegates
    Help.

    I hope that helps.

    Rgds, Phil

    "Gerda" <Gerda@discussi ons.microsoft.c om> wrote in message
    news:41DF02A3-1B7B-49CF-877C-A76C615CA228@mi crosoft.com...[color=blue]
    > Hi!
    >
    > I've implemented many times an asynchronous call of a method with a call
    > backfunction successfully.
    >
    > But to implement this with VB.NET is not so successfully. I can implement
    > all events ProcessingEvent , CompletedEvent, etc.
    > It works fine and copies all files in the background ...
    >
    > Bit to make it perfekt I want to implement a callback function wich will
    > be
    > used to do the final work, show the finished message and so on.
    >
    > With C# I can do that with a BeginInvoke() on the event object. Looks like
    >
    > callback = new AsyncCallback(C opyCompletion);
    > DoCopy.BeginInv oke(this, args, callback, args);
    >
    > But it is not possible to use BeginInvoke in that way in C#.
    >
    > How can I do that?
    >
    > Thanks for your help
    >
    > Gerda[/color]


    Comment

    • Gerda

      #3
      Re: put in a asynchronous call with a callback

      Hi Phil!

      Your explanation about the use of delegates ar right!

      Maybe my statements were not clear. I want to use the event keyword as
      antagonism to the delegate keyword!

      Why? I don't want to use delegates because anyone is able to access a public
      delegate, can add subscribers to it and can fire the event - as well when
      there is no event on the publisher side.
      When you use a event only the publisher class can fire the event. Coexistent
      anyone can add metods to the delegate list.

      That's why I want to use events as reasonable contradistincti on to delegates.

      But my problem is that it seems to be that you can't use events in VB.NET in
      the same way in C#.

      When you you use VS.NET and type in C# the '.' behind the event variable you
      get with the help of intellisense the whole bunch of methods and properties
      you also get with a delegate variable. But when you do that in VB.NET you
      receive nothing at all with the help of intellisense. There seems to be no
      way to use delegate methods, etc. with events in VB.NET!

      I want to implement the BeginInvoke() method to put in an callback methode.
      But not on a delegate variable but on a event variable.

      How to to that?

      here is a little sample code:

      public event CopyHandler CopyEvent;

      public void RunCopyAsync(ob ject argument)
      {
      if (DoWork != null) // in VB.NET this is not necessary - it's done
      automatically
      {
      DoCopyEventArgs args = new DoCopyEventArgs (argument);
      AsyncCallback callback;
      callback = new AsyncCallback(R eportCopyComple tion);
      CopyEvent.Begin Invoke(this, args, callback, args);
      }
      }

      "Phil G." wrote:
      [color=blue]
      > Hi Gerda,
      >
      > Fortunately you are mistaken. VB.Net uses the same classes and methods. See
      > my response to Brad Rogers, dated 13/9/05 (UK date :-) and titled Delegates
      > Help.
      >
      > I hope that helps.
      >
      > Rgds, Phil
      >
      > "Gerda" <Gerda@discussi ons.microsoft.c om> wrote in message
      > news:41DF02A3-1B7B-49CF-877C-A76C615CA228@mi crosoft.com...[color=green]
      > > Hi!
      > >
      > > I've implemented many times an asynchronous call of a method with a call
      > > backfunction successfully.
      > >
      > > But to implement this with VB.NET is not so successfully. I can implement
      > > all events ProcessingEvent , CompletedEvent, etc.
      > > It works fine and copies all files in the background ...
      > >
      > > Bit to make it perfekt I want to implement a callback function wich will
      > > be
      > > used to do the final work, show the finished message and so on.
      > >
      > > With C# I can do that with a BeginInvoke() on the event object. Looks like
      > >
      > > callback = new AsyncCallback(C opyCompletion);
      > > DoCopy.BeginInv oke(this, args, callback, args);
      > >
      > > But it is not possible to use BeginInvoke in that way in C#.
      > >
      > > How can I do that?
      > >
      > > Thanks for your help
      > >
      > > Gerda[/color]
      >
      >
      >[/color]

      Comment

      Working...