简体   繁体   中英

Asp.net C# Asynchronous call to Web Service method

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 ie 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM