1

I would like to have a async action in a MonoRail basecontroller.

I read the documentation about asynchronous actions http://docs.castleproject.org/Default.aspx?Page=Controllers&NS=MonoRail&AspxAutoDetectCookieSupport=1#Asynchronous_Actions_1

So this is what I did:

public IAsyncResult BeginUploadTags(HttpPostedFile xmlFile, Boolean doUpload)
{
  if(IsPost)
  {
            IAsyncResult iAsyncResult = new AsyncDelegate(upload).BeginInvoke(queryResult, doUpload, ControllerContext.Async.Callback, ControllerContext.Async.State);
            return iAsyncResult;
   }
   // TODO
   // if IsPost is false do nothing but return a IAsyncResult object
}

public void EndUploadTags()
{

}

private delegate void AsyncDelegate(List<String> queryResult, Boolean doUpload);
private void upload(List<String> queryResult, Boolean doUpload)
{
   // do upload stuff
}

But what do i need to do when IsPost is false?

ZxCvBnM
  • 277
  • 3
  • 14
  • Can you simply return a completed IAsyncResult (with a null AsyncResult) similar to what is described in another SO question? (http://stackoverflow.com/questions/5037422/how-to-create-an-iasyncresult-that-immediately-completes) – Ken Egozi Oct 24 '12 at 18:46
  • Thanks, this will probably work. – ZxCvBnM Oct 30 '12 at 10:01
  • Glad to see that this helps you, I'll make it into an answer so people will be able to see it clearly as well – Ken Egozi Oct 30 '12 at 21:08

1 Answers1

0

You would need to return a completed IAsyncResult (with a null AsyncResult value).

You can create a completed result similar to the one at this SO question

Community
  • 1
  • 1
Ken Egozi
  • 1,825
  • 11
  • 14