开发者

Designing Multi-Tier application to use progress bar

开发者 https://www.devze.com 2023-01-30 00:46 出处:网络
I have a multi tier application in c# that is supposed to perform tasks on a database (If first time use, we may create the database and fill it with some data). When I initially designed the applicat

I have a multi tier application in c# that is supposed to perform tasks on a database (If first time use, we may create the database and fill it with some data). When I initially designed the application I didn't account for a possible progress bar control, let alone any reporting of progress of any sort. How can I modify the design of the application to be able to report database operations progress to the UI layer? Is there a solution out there that 开发者_开发百科is reusable and doesn't force me to modify all my functions to take additional inputs for the reporting?


As Greg said, there's a lot of work ahead. However, there are many ways in which to approach the problem, and the best for you depends on what contextual information passes down from the client to the application/database layers already. For example, if a session token or transaction identifier is passed from the client to the application in the normal course of executing a query/transaction or an acknowledgement reference passed back asynchronously from the application to the client, then for those queries/transactions for which progress reporting was necessary you could have the application update a status table that the client could query. This could reduce the amount of re-work required. Basically, you need to consider the "middleware" in place already and see if any of that can be leveraged to correlate transactions across tiers.


No. Depending on how large your application is, you have a lot of work ahead of you.

For progress reporting to work, you need the code which is performing the work to raise events when a unit of work is completed. That event needs to be handled at the UI layer and progress indicators updated.

A good place to start would be to look into using BackgroundWorker (there is an example on MSDN here - http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx). Once you're familiar with the BackgroundWorker you should be in a better position to decide which changes you need to make to your application.


You could modify the server code so that it updates progress information at the server end (without changing function signatures), and then have a separate method that can query this information separately.

This would allow you to retrofit support for progress without having any impact whatsoever upon your existing calls to the server, just add a new background thread on the UI checking for updated progress information while a long running task is underway.

Edit: I guess the same approach would work for tasks that take place in the client. But still, a static progress indicator class could be used here too.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号