1

I have a following scenario:

1) User uploads a file via Asp.net web page.
2) Web page passess the file to FileFlowManagerBLL which checks the file and uploads it to the database
3) I would like to call a background web service method, which is by the way in the same project, so that the web service starts a huge job of number crunching from the uploaded file. After calling the web service method I would like to return the control back to the user without waiting for it to finish, displaying a message that the file has been update successfully and user will receive an email once the data crunching is complete.
4) Web service completes the number crunching in lets say 30 - 60 mins or may be more and calls the relevant code that sends an email to the user.

I need some quidance for implementing step 3 i.e. how to call a web service method asynchrously so that the control is returned to the user and he/she can view other pages of the web application while the number crunching is being done.

3
  • This is a fairly popular question, but I'm struggling to find a recent duplicate. The one in the related area is way out of date. Commented Feb 10, 2015 at 13:19
  • Yes, I tried to find it as well but couldn't find an up to date version! Commented Feb 10, 2015 at 13:23
  • 2
    Here is a useful article - blog.stephencleary.com/2014/06/fire-and-forget-on-asp-net.html Commented Feb 10, 2015 at 13:31

1 Answer 1

1

One way would be to host your WCF service as a Windows service. Your initial web service (after it checks the file) could write it to a certain directory. Then in your Windows Service you can create a FileSystemWatcher that looks for new files in that directory, and if it finds any can call your processing method.

Sign up to request clarification or add additional context in comments.

2 Comments

c# ASMX web service already exists so it would be easier to call its method asynchronously (somehow). I am sure there must be a way.
There are lots of examples on how to call a method asynchronously from your .net client page, and then wait for a result. However, your example is slightly different. You don't want to wait for your long running process to complete, in order to send web page a response. You want to check the file, start the long running process, and then return to the client before the long process is finished. I would hiighly recommend you have a different self-hosted WCF Windows Service that runs the long process, and just have your web service call that service. Something like this should be distributed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.