2

I am new to delegates for asynchronous calling. I am using the following code to call a UploadVideo method asynchronously.

UploadVideoDelegate delUploadVideo;        
AsyncCallback objAsyncCallBack = new AsyncCallback(this.TocuhLogResult);        
IAsyncResult objIAsyncRes;        
delUploadVideo = new UploadVideoDelegate(UploadVideo);        
objIAsyncRes = delInsertTouchLogToDB.BeginInvoke(videos[videocount++],           objAsyncCallBack,     null)

But, how can I notify that your upload is completed on client-side. Like showing a message that upload is Completed.

Fred
  • 3,365
  • 4
  • 36
  • 57
donstack
  • 2,557
  • 3
  • 29
  • 44
  • is there any one can help on this? – donstack Mar 12 '13 at 14:27
  • You have defined a callback method called `TocuhLogResult` - when your method completes the callback will be called. Call `EndInvoke` from the callback and you know the method has completed. There are many samples out there for this. – Daniel Kelley Mar 12 '13 at 14:38
  • What EndInvoke will do? Can you throw some more light or any reference – donstack Mar 12 '13 at 14:42
  • I really recommend you do your own research before using parts of the language you are not familiar with. A simple search returned [this](http://stackoverflow.com/questions/1712741/why-does-asynchronous-delegate-method-require-calling-endinvoke) result. – Daniel Kelley Mar 12 '13 at 14:46
  • ok, thanks for your suggestion but EndInvoke is not helping anyway to update any Label on webpage. – donstack Mar 12 '13 at 14:49
  • Of course it isn't. As I said, `TocuhLogResult` will be called when your delegate has finished executing. Within there you should call `EndInvoke` and write any code you need to update your label. – Daniel Kelley Mar 12 '13 at 14:52
  • 2
    The callback will be invoked when the work is complete on the server, but this will not be done in the context of the initial request, right? So how can you notify the browser of an event on the server? Either the browser polls or you push with Web Sockets (which you probably aren't using). – bmm6o Mar 12 '13 at 16:32
  • @bmm6o you catched the right thing. I am not getting any way to push the message to client side. – donstack Mar 14 '13 at 16:35

0 Answers0