Display progress of execution through progress bar

前端 未结 5 2209
情话喂你
情话喂你 2020-12-28 21:42

I have a silly problem but i am stuck. I am executing a stored procedure form my code procedure takes time so for this I am displaying a progress bar, which shows the progre

5条回答
  •  礼貌的吻别
    2020-12-28 22:09

    Please follow this method.

    1. First calculate the time to execute the stored procedure. db.Database.ExecuteSqlCommand("myquery"); enter code here

    2. Allocate a separate thread/(part of process) for the execution of this query. by using the background worker control in c# (in do_work Event)

    3. similarly assign an separate process thread using a background worker for displaying the progress-bar status.(in Progress-Changed Event) just increment value by 10%. give some small sleep (based on the time to consume your query divide it into ten parts). On completion make Progressbar.value=100 (in Run-Worker-CompletedEvent)

    Please call both thread at mean time in backgroundWorker1.RunWorkerAsync();

    I think this solves your Problem.


提交回复
热议问题