0

I have a big project (30ish developed classes) and I want to make a loading bar for it. I have a current progress and total progress bars. I also have to roughly describe what is happening during the current process.

The way that I did it is manually (haters gonna hate) go through the most greedy process and did estimations of how long it is gonna take (when it is a for loop, just do step ups each iteration).

I read that Background_Worker would be much more smoother, but as I read on, it appeared to me that I still do have to go to every chunk of code and say that I want to increment the progress bar (The idea that I have to do it do describe the process made sense to me).

So my question was: is there a way to sort of encapsulate your method in a "block", which would automatically allocate the progress bar times? Or is there a more efficient way to do what I'm doing?

4

3 回答 3

1

最好的方法是把你的主要处理放在一个不同的线程中,以免你的 GUI 过载,这样它就不会冻结(用户感到沮丧),然后在 GUI 线程中做你的进度条(或者也为进度条创建另一个线程)。一切都取决于偏好。

但从来没有!冻结用户界面。用户只是认为它已经死了,并试图强制关闭它。

于 2013-05-27T14:52:11.710 回答
0

也许是带有进度条的后台工作人员。使用全局变量来存储进度。

public class SomeClass
{
   public int Progress { set; get; }

   public void Method1() 
   {
      ...
      Progress++; 
   }

   public void Method2() 
   {
      ...
      Progress++; 
   }

   ...
}

在调用每个方法时,增加进度并调用后台工作人员报告进度。

我知道有更好的解决方案,但这只是一个想法。

于 2013-05-14T02:12:50.003 回答
0

有没有办法将你的方法封装在一个“块”中,它会自动分配进度条时间?

  • 不,进度条用于显示进度,因此您必须在外部(来自调用者)设置startendcurrent state值,因为只有调用者知道它将执行什么并且可能控制它。

  • 是的,如果您将无限条可视化,它可能不会向用户提供有关操作执行的一些定量信息,但会告知他正在发生的事情。您还可以提供一些文本描述,这些描述会根据当前操作进行更改,因此用户可以看到“那里正在发生一些事情”。

从 UX 的角度来看,没有什么比这更糟糕的了,然后让用户穿着制服,在正在做某事的 UI 面前感到困惑,这并不清楚。

所以这两种方法都很好,imo。

于 2013-05-13T20:51:56.630 回答