473,406 Members | 2,549 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,406 software developers and data experts.

BusyBox Revisited

Hi again experts.

Still having problems with the backgroundworker etc. Here is my test
simulation.

Form1 has a start button
BusyBox has a ‘Please Wait…’ label
Form2 has no controls

When start is clicked, display the BusyBox with a delay. The BusyBox should
also display a progressbar, animated gif or anything that move to indicate
something is happening. After the delay, the BusyBox closes and Form2 is
shown.

Here is my code where I cannot even get the label to display !

Thanks in advance for any help or advice.

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs
e)
{
BackgroundWorker bw = sender as BackgroundWorker;
TimeConsumingOperation(bw);

}

private void backgroundWorker1_RunWorkerCompleted(object sender,
RunWorkerCompletedEventArgs e)
{
Form frm = new Form2();
frm.Show();

}

private void TimeConsumingOperation(BackgroundWorker bw)
{
Form frmB = new BusyBox();
frmB.Show();

long i = 0;
while (i != 3000000000)
{
i++;
}
frmB.Dispose();
}

private void startBtn_Click(object sender, EventArgs e)
{
this.backgroundWorker1.RunWorkerAsync();
}

Mar 14 '07 #1
3 2001
I think your problem is that you're displaying the busy form on the
worker thread... not what you want to do.

Instead, perhaps you can have the process when kicks off the
background worker start a timer to go off in a certain amount of time,
start the BW. That way the UI thread is handling the UI details and
the worker is handling whatever it needs to.

In the ReportProgress callback (if you're using it) you can check if
the busy box is currently shown and if it is, tell it to update its
progress bar.

HTH
Andy

Mar 14 '07 #2
Hi Andy,

Many thanks for trying to help. I can't believe something like this is so
difficult. I tried putting the code (see below) on a different thread but
again the BusyBox form will not display the 'Please Wait..' text or gif.

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
Thread trd = new Thread(new
ThreadStart(this.TimeConsumingOperation));
trd.IsBackground = true;
trd.Start();
}

private void TimeConsumingOperation()
{
Form frmB = new BusyBox();
frmB.Show();

long i = 0;
while (i != 3000000000)
{
i++;
}
frmB.Dispose();
}
}

Mar 16 '07 #3
jez123456 <je*******@discussions.microsoft.comwrote:
Many thanks for trying to help. I can't believe something like this is so
difficult. I tried putting the code (see below) on a different thread but
again the BusyBox form will not display the 'Please Wait..' text or gif.
You've still got the form on the same thread as the time consuming
operation though - you do both in TimeConsumingOperation. (And you
don't have a windows message pump on the new thread anyway...)

Create and show the form in your event handler, and start the other
thread to do the actual work.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 16 '07 #4

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

Similar topics

0
by: JimC | last post by:
Some months ago, I presented a 30-day sliding calendar in PHP that had a bug that I finally fixed. Code for this and other procedures in PHP, C/C++, Tcl/Tk, Java, stuff with windows and widgets,...
12
by: Roger Price | last post by:
Thank you to Yang (Is that your first name?) and Andy for your suggestions. I am 99% of the way there but now cannot get the "Reset" button to work. I have included the whole of my code and...
6
by: R. Rajesh Jeba Anbiah | last post by:
Sometimes ago I started a thread <http://groups.google.com/groups?threadm=abc4d8b8.0404012208.76ebdba7%40posting.google.com> <Previous post> I'm supposed to hide the php extension in a file...
2
by: Pieter Van Waeyenberge | last post by:
Hello i *had* it working ... i have everything in place as all documentation and fora stated.. but yet i AGAIN get the error: "The used command is not allowed with this MySQL version" in...
1
by: Raoul Watson | last post by:
This has probably been covered many times and I apologize for losing the code. I am looking for code to play a midi file and at the same time, report back (or be able to status check), whether...
2
by: Bengt Richter | last post by:
Why wouldn't quote-stuffing solve the problem, and let you treat \ as an ordinary character? In a raw string, it's no good for preventing end-of-quoting anyway, unless you want the literal \ in...
21
by: Chris Reedy | last post by:
For everyone - Apologies for the length of this message. If you don't want to look at the long example, you can skip to the end of the message. And for the Python gurus among you, if you can...
5
by: sandman | last post by:
I've been testing my web app on another workstation to simulate using the server time. The test pc's time is an hour behind the server time and when the user processes a request, the server time...
1
by: | last post by:
i'm testing dban 1.07 with busybox 0.65, but compilation does not succeded. i installed busybox, but i have problem with _syscall function. i can include the function header into the project? ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.