473,398 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

showing form while processing

I have form with progress bar ,when application begin processing and progress
bar moving if I minimized the form and try to restore it ,it is not showing
until the processing completed ,how can I enabled minimize, maximize moving
form while processing in underway?
Nov 17 '05 #1
8 3252
Try calling Application.DoEvents from within the loop of your long process.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Raed Sawalha" <Ra*********@discussions.microsoft.com> wrote in message
news:F7**********************************@microsof t.com...
I have form with progress bar ,when application begin processing and
progress
bar moving if I minimized the form and try to restore it ,it is not
showing
until the processing completed ,how can I enabled minimize, maximize
moving
form while processing in underway?

Nov 17 '05 #2
Alternatively, run the long process on a thread other than the UI thread.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Raed Sawalha" <Ra*********@discussions.microsoft.com> wrote in message
news:F7**********************************@microsof t.com...
I have form with progress bar ,when application begin processing and
progress
bar moving if I minimized the form and try to restore it ,it is not
showing
until the processing completed ,how can I enabled minimize, maximize
moving
form while processing in underway?

Nov 17 '05 #3
Hi,

Create a thread and do the processing in that thread, you then have the UI
thread to react as usual, to update the progressbar you have two options,
you can use a timer to update it, or if your process is interactive ( like
a loop ) you could send an event to the UI ( using Control.Invoke ) at the
start of each iteration, you could pass info regarding the status or for
example what file you are processing, etc

post back if you need some code, I should have some instances around here.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Raed Sawalha" <Ra*********@discussions.microsoft.com> wrote in message
news:F7**********************************@microsof t.com...
I have form with progress bar ,when application begin processing and
progress
bar moving if I minimized the form and try to restore it ,it is not
showing
until the processing completed ,how can I enabled minimize, maximize
moving
form while processing in underway?

Nov 17 '05 #4
I did the bother Approches as Bob Said and you also , but i do not know i
think i did something wrong first i tried to call Application.DoEvents();
also i built a Thread Class

class ThreadClass
{
public ThreadClass(string mydata....etc){//I initialized my data}
public void Process(){//Do my work}
}

in main form function=> didi
ThreadClass oclass = new ThreadClass(pass params)
Thread oTh = new Thread(new ThreadStart(oclass.Process));
oTh.Start();
oTh.Join();

but still can not move,maximize the form???any suggestion

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Create a thread and do the processing in that thread, you then have the UI
thread to react as usual, to update the progressbar you have two options,
you can use a timer to update it, or if your process is interactive ( like
a loop ) you could send an event to the UI ( using Control.Invoke ) at the
start of each iteration, you could pass info regarding the status or for
example what file you are processing, etc

post back if you need some code, I should have some instances around here.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Raed Sawalha" <Ra*********@discussions.microsoft.com> wrote in message
news:F7**********************************@microsof t.com...
I have form with progress bar ,when application begin processing and
progress
bar moving if I minimized the form and try to restore it ,it is not
showing
until the processing completed ,how can I enabled minimize, maximize
moving
form while processing in underway?


Nov 17 '05 #5
Hi,

If you are using a thread you have no need to call Application.DoEvents.

First of all, you HAVE to remove the call to Join() it will block the UI
thread

Now a silly question: How do you increment the progressbar?
I think you have two options:
1- use a timer in the UI thread right after you create your now thread and
before.
2- fire an event from the worker thread as I suggested before.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Raed Sawalha" <Ra*********@discussions.microsoft.com> wrote in message
news:E6**********************************@microsof t.com...
I did the bother Approches as Bob Said and you also , but i do not know i
think i did something wrong first i tried to call Application.DoEvents();
also i built a Thread Class

class ThreadClass
{
public ThreadClass(string mydata....etc){//I initialized my data}
public void Process(){//Do my work}
}

in main form function=> didi
ThreadClass oclass = new ThreadClass(pass params)
Thread oTh = new Thread(new ThreadStart(oclass.Process));
oTh.Start();
oTh.Join();

but still can not move,maximize the form???any suggestion

"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Create a thread and do the processing in that thread, you then have the
UI
thread to react as usual, to update the progressbar you have two options,
you can use a timer to update it, or if your process is interactive (
like
a loop ) you could send an event to the UI ( using Control.Invoke ) at
the
start of each iteration, you could pass info regarding the status or for
example what file you are processing, etc

post back if you need some code, I should have some instances around
here.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Raed Sawalha" <Ra*********@discussions.microsoft.com> wrote in message
news:F7**********************************@microsof t.com...
>I have form with progress bar ,when application begin processing and
>progress
> bar moving if I minimized the form and try to restore it ,it is not
> showing
> until the processing completed ,how can I enabled minimize, maximize
> moving
> form while processing in underway?


Nov 17 '05 #6
ok what should i do to make thread working other thank Join()

I increment the progress bar using PerformStep()
first i set the value as the number of file will be processed, then do call
PerformStep
"Ignacio Machin ( .NET/ C# MVP )" wrote:
Hi,

Create a thread and do the processing in that thread, you then have the UI
thread to react as usual, to update the progressbar you have two options,
you can use a timer to update it, or if your process is interactive ( like
a loop ) you could send an event to the UI ( using Control.Invoke ) at the
start of each iteration, you could pass info regarding the status or for
example what file you are processing, etc

post back if you need some code, I should have some instances around here.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Raed Sawalha" <Ra*********@discussions.microsoft.com> wrote in message
news:F7**********************************@microsof t.com...
I have form with progress bar ,when application begin processing and
progress
bar moving if I minimized the form and try to restore it ,it is not
showing
until the processing completed ,how can I enabled minimize, maximize
moving
form while processing in underway?


Nov 17 '05 #7

"Raed Sawalha" <Ra*********@discussions.microsoft.com> wrote in message
news:E3**********************************@microsof t.com...
ok what should i do to make thread working other thank Join()
It will be scheduled to start as soon as you call Thread.Start()
I increment the progress bar using PerformStep()
first i set the value as the number of file will be processed, then do
call
PerformStep


In this case you should fire an event from the thread each time a new file
is going to be processed. Let me dig around and see if I have an example
that does exactly that. you could also search in google this has been
answered before

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Nov 17 '05 #8
Hi!

I have had the same problem to you, Read. Thanks all who gave here all
the clues. I thought that you, Read, possibly would like to see see the
solution i did thanks to these clues.
Here is my code (to make it more clear I removed not very important
code):
private void button1_Click(object sender, System.EventArgs e)
{

System.Threading.Thread newThread =
new System.Threading.Thread(new
System.Threading.ThreadStart(this.CreateBitmap));
newThread.Start();

}

private void CreateBitmap()
{

pBar.Minimum = 1;
pBar.Maximum = bmp.Height;
pBar.Value = 1;
pBar.Step = 1;
int y;
double percent ;

for(y=0; y < bmp.Height;y++)
{
// do your work
pBar.PerformStep();
percent = (((y*1.00)/pBar.Maximum)*100);
this.label1.Text = "Completed: " + Math.Ceiling(percent).ToString()
+ " %";

}
}

Cheers!
*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Noor | last post by:
Hi All How some application shows animation to show if some progress/processing is going on. like especially in the end of some wizard, the application shows animation on a form, animation...
3
by: Coskun Cavusoglu | last post by:
Hi, What I want to know is when a user clicks on a button I send him to another page by using the Response.Redirect("") method. But the page that the user is being sent to has to generate a...
2
by: Krzysztof Karnicki | last post by:
I would like develop Form on my Windows Application, that is going to notify the user, just like Microsoft Office 2003 shows that there are new mail coming. When I use System.Windows.Forms.Form and...
4
by: Mika M | last post by:
Hi! If Windows Form -application has for example a button on Form1 which Click-event opens other Form2-form like... Dim f as New Form2 f.ShowDialog() If (f.DialogResult = DialogResult.OK)...
2
by: Dzemo | last post by:
I want to show some form with animated gif on it (Form1) while some data are processed in background in application. I use dim x as new Form1 x.show for I=0 to 1000000 processing data next I
4
by: Larry R | last post by:
I am trying to set a panel (that holds a progress image) to be visible when a long running process is happening. Sounds simple, right :) What happens is the panel never becomes visible. The load...
7
by: needin4mation | last post by:
Hi, I have an Access 2002 - 2003 database. I am using Access 2003. Whenever I link an image all it shows is the filename. Not the image. Other versions of Access can link the image just fine. ...
2
by: Luongo | last post by:
Hi, I have a form that, when submitted, needs to be processed by one file (survey.php) but have another page (thankyou.php) displayed. Because I don't have access to the former, I can't combine the...
4
by: rb0135 | last post by:
Hi, I am writing a C# mobile 6 (dot.net 3.5) application. On the form, I have a label. I update this label with text as my initalizing routines are running (from the form load event), such as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.