3

I have a web-application which have Android and iPhone application too with centralized database. On some event I have to perform some database operation from both web & web-services and send various SMS, email and push notification to both Android & iPhone application (At-least 10-15 at a time). All these process are taking too much time and user need to wait till all operation being completed. To overcome this issue I have implemented background process (for the first time), which also take same time, Please review below code and let me know is I am implementing background process correctly or there is some other method to do so..

private readonly BackgroundWorker worker = new BackgroundWorker();

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
 try
 {
   FunctionToBePerformInBackground();    
 }
 catch
 {
 }
}
void Page_Load(object sender, EventArgs e)
{
  worker.DoWork += new DoWorkEventHandler(backgroundWorker1_DoWork);
}
protected void buton_click(object sender, EventArgs e)
{
  worker.RunWorkerAsync();
}

Thanks In Advance..

Tarun Mathur
  • 865
  • 1
  • 8
  • 25
  • try this one: http://www.dotnetfunda.com/articles/show/613/background-processes-in-asp-net-web-applications – Robert Aug 18 '14 at 10:45
  • Thanks Robert for your suggestion, but in above article background process is performed on Global.asax file, but I need to perform it in business manager layer as same function will call through web and web-services with multiple users simultaneously. – Tarun Mathur Aug 18 '14 at 11:20
  • I guess you need some background job/service which would take requests from a queue. The queue would be filled by requests coming from asp .net. The job could be a windows service, thread or a stand alone application. – Robert Aug 18 '14 at 11:26

0 Answers0