Click here to Skip to main content
15,867,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In my WPF application,

When user click on the export button,I am exporting large data to the .CSV file.

for this process i am using backgroundworker. Here its exporting fine and its take long time.

At the same time i need to update Progress Bar.

For this reason,i need a solution like.

In the background worker, we need to use two stored prcedures.

1.for getting the result.(Main stored procedure).
here we are using cmd.executereader for reading and writing to the .csv file.

2.we will get status from another stored procedure.

my problem is how can we run both the stored procedures at the same time in background.
one stored procedure for execution and another stored procedure for update the progress bar.


Please let me know how can proceed with this.
Posted

1 solution

I think many ways you can do that.
1.You can use 2 Backgroundworker instance for execute 2 different procedure.
2. You can use 1 Backgroundworker which will update your progressbar another you can create a thread and run that thread as background thread. That will execute your another procedure.
3. You can use 1 Backgroundworkder for updating your ui element progressbar, another you can execute your another procedure asyncronously using delegate(BeginEndvoke, EndEndvoke).
4. You can also use TaskParallel component for asyncronous procedure execution if you use dotnet framwork 4/4.5.
Note: for parallel/asyncronous stored procedure execution, your connection string need to set connection string property Async = true. Otherwise it will fail.
 
Share this answer
 
Comments
dmunisubbu 28-Mar-13 23:38pm    
Thank you,
can you please post do you have any examples
S. M. Ahasan Habib 28-Mar-13 23:59pm    
Sorry! I have no example in my hand at the moment. How to use progress bar i find a url
http://www.dotnetperls.com/progressbar
Just remember that database stored procedure execution is time is no deterministic and when it will finish you did not know. So you can not set any perfect progress bar end result. You need to use trick here.
dmunisubbu 29-Mar-13 0:12am    
yes i am trying with the first option.
thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900