Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
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 28-Mar-13 17:27pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
dmunisubbu at 28-Mar-13 23:38pm
   
Thank you,
can you please post do you have any examples
S. M. Ahasan Habib at 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 at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 334
1 Kornfeld Eliyahu Peter 325
2 Maciej Los 239
3 OriginalGriff 188
4 King Fisher 185
0 OriginalGriff 6,303
1 DamithSL 4,764
2 Maciej Los 4,306
3 Kornfeld Eliyahu Peter 3,914
4 Sergey Alexandrovich Kryukov 3,538


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 28 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100