How to use progressbar with the reference of processname as the time limit.  
Author Message
041661K





PostPosted: Visual Basic Language, How to use progressbar with the reference of processname as the time limit. Top

HEY EVERYONE,

I would like to know how to get about doing this;

I wanted to do a loading which have the progress bar.So i want the progress bar to load according to the time taken by the process which will be refer using the processname..can some kind soul help me....Thankss

Regarad Abu,




Visual Basic11  
 
 
Mattias Sjogren





PostPosted: Visual Basic Language, How to use progressbar with the reference of processname as the time limit. Top

You can't know for sure how long a process will take to load if that's what you're asking. Perhaps you should consider using some other form of progress indicator (like a continuous animation or something).



 
 
DMan1





PostPosted: Visual Basic Language, How to use progressbar with the reference of processname as the time limit. Top

Me.ProgressBar1.Minimum = 0

Me.ProgressBar1.Maximum = 100

Dim Counter As Integer = 0

Dim p As Process = Process.Start("Notepad.exe")

Do Until p.WaitForInputIdle()

If Counter >= 100 Then

Counter = 0

End If

Me.ProgressBar1.Value = Counter

Counter += 1

Loop

Me.ProgressBar1.Value = 100

the above code will cycle through 0 to 99 and single step the progress bar until the started app is idle....

The is a caveat with using "waitForIdleInput" see the following....

Return Value

true if the associated process has reached an idle state; otherwise, false.

Collapse imageRemarks

Use WaitForInputIdle to force the processing of your application to wait until the message loop has returned to the idle state. When a process with a user interface is executing, its message loop executes every time a Windows message is sent to the process by the operating system. The process then returns to the message loop. A process is said to be in an idle state when it is waiting for messages inside of a message loop. This state is useful, for example, when your application needs to wait for a starting process to finish creating its main window before the application communicates with that window.

If a process does not have a message loop, WaitForInputIdle immediately returns false.

This overload of WaitForInputIdle instructs the Process component to wait indefinitely for the process to become idle in the message loop. This instruction can cause an application to stop responding. For example, if the process is written to always exit its message loop immediately, as in the code fragment while(true).