Sunday, 20 July 2014

Show animated wait window ,while processing request

Its a major problem faced while processing DB request else functions etc .

The problem is when we perform command on database it takes time of few seconds, at that time my applications main window becomes halted.
when i performs command on database execution returns on main application when whole command is executed on database.
Just Like "NonQuery()"
Lets assume we are working on 4.0 and sending request to view.  i am showing a form before it and closing that form after the command, but problem is i am putting a GIF image on the form, because exection is halted on main application, the gif don't shows animation until the command is executed.
so that i putted it on a BackGroundWorker, but main thread is halted so its child tread also become halt.
we can not put database transaction in background worker, becuase sometime working is depended on result retrieved from database, and we want to halt application untill data is not fetched, but in this case also we want that on wait form, the gif image should show its animation.
What to do in this case, and how to do ?
For that no need of large block of code.
<asp:UpdateProgress ID="updateProgress1" runat="server">'
       <div id="progressBackgroundFilter">
           <div id="processMessage" style="text-align: center">
            <asp:Image ID="imgLoader" runat="server" ImageUrl="~/Images/loader.gif" />    <br />
Same problem I faced while processing request from Windows application.
That time , we normally used Thread class and its methods
Thread query = new Thread(() => Method("Method", "Parameters", Blah));
  query.Start();    //start your animation
  while (query.IsAlive)   {
    Thread.Sleep(10);    }
I don't have any idea about  BackgroundWorker  in windows form. But you can try with it.

No comments:

Post a Comment