Home > Net >  Unable to determine the time of operation, how to use progress bar?
Unable to determine the time of operation, how to use progress bar?

Time:10-26

Such as operating
 for (int a=0; A. & lt; 2001; +) 
{
For (int b=0; B & lt; 2001; B++)
{
For (int c=0; C & lt; 2001; C + +)
{

If (a * * b=a + b=c * c & amp; & A + b + c==2000)
{
MeNum. Text +=$" is {a}, b is {b}, c is {c}. \ r \ n ";
}

}
}
}


Interface feign death, how to determine if use backgroundWorker or Thread.

CodePudding user response:

reference
if use backgroundWorker or Thread how to determine progress.


Those data can be scrapped, like Java will not to talk about in SSH, j2ee, the void void,

As for you this task and IProgress You this question, of course, a slightly itself, because of the progress bar first need to know the total, to use a progress, but you that we are unable to determine the total number in advance, can only tell you how much we have to deal with, and finally he did not finish, but can't tell you how much is left, of course if you forcibly 2001 * 2001 * 2001 first tell us how many, we can display progress

 var progress=new Progress (a); 
Progress. ProgressChanged +=(send, e)=& gt;
{
The Console. Write ($" current processing to {e} ");
};

Task. WhenAll (Program.com pute (progress). ContinueWith (p=& gt;
{
The Console. Write (" I figured out ");
});

The static IEnumerable Compute (IProgress Progress)
{
int count=0;
For (int a=0; A. & lt; 2001; +)
{
For (int b=0; B & lt; 2001; B++)
{
For (int c=0; C & lt; 2001; C + +)
{
Yield return Task. Run (()=& gt;
{
If (a * * b=a + b=c * c & amp; & A + b + c==2000)
{
Console. WriteLine ($" is {a}, b is {b}, c is {c} ");.
}

Interlocked. Increment (ref count);
The progress Report (count);

});


}
}
}
}


Ps: new.net framework IAsyncIEnumerable asynchronous iterator that can be done more simple, is still the problem, of course, because I don't know the total number of, we can not show the progress, can only reflect current has been dealt with how many, how much is left no response, how much is left after all is dynamic

CodePudding user response:

So you will find that Microsoft installation package and rar compressed package, show progress are two floors up and down

Microsoft's installation package
First tell you what I'm in the download file, download progress how much
Ceng 2 is to tell you what I installed heating, installation progress how much

Zip
The first layer, a total of how many files
Layer 2, I'm a single extract, extract the progress how much

They are the cause of this design so, unable to determine the total amount, reaction is currently doing

CodePudding user response:

In progress bar with the same rar reaction this problem

He is not only up and down two floors, he was also on the progress of the designed depth is 2 colors

To indicate the total number of dynamic and complete

CodePudding user response:

Not sure of the time the operation of the corresponding position,
So why the progress bar, designed the load wait no more reasonable some directly?
On the contrary, if you can by judgment, such as the size, or the time threshold as well as the progress bar,

CodePudding user response:

Set a global variable, loop real-time change more value (such as a percentage), then the asynchronous thread set this value to the current value of the progress bar,
  •  Tags:  
  • C#
  • Related