Click to See Complete Forum and Search --> : Delay method in C#
rusky
January 19th, 2003, 10:38 AM
Is there such a method?
Like the Delay(time) in dos.h for c++ ?
Oh..and one more thing.. if I want to make a splash screen before running my app... i.e. I show this form with a picture.. it's got a label saying "loading", and after a short while the form disappears and the app shows up , how would I go about doing that ?
I haven't found any OnFinishedLoading type of methods...
10x... :) mIRC addict..please eXcuse me... :)
Dreamon
January 19th, 2003, 11:42 PM
You can use the Thread class.
I think it's something like this:
Thread oThread = new Thread();
oThread.Suspend(1000);
or something like that. I'm not sure about what the "pause" method is called. You'll be able to figure it out.
Hope this helps.
pareshgh
January 20th, 2003, 12:29 AM
if you just want to sleep then no need to create even thread object.
Thread.Sleep(...)
sleep for you while you think
:D
Paresh
rusky
January 20th, 2003, 12:46 AM
thanks guys! :)
rusky
January 22nd, 2003, 01:43 PM
BTW... back to my initial question.. or the last part of it to be more precise... is there any event I can call to let me know when a form has finished loading ( like finished loading controls and has succesfully displayed them to the user...)
I am asking this because if I use the Thread.Sleep(x) method... the problem is it is getting called before the form finishes displaying it's controls and the result is a big black spot on the screen for the x duration..:D
pareshgh
January 22nd, 2003, 02:04 PM
i.c,
You could use Timer control which does that for you.
and you could apply simple logic like this,
bool bLoaded = false;
which you will declare in class member.
on form load method
void Form1_Load(...)
{
..............do all control loading
bLoaded = true;
}
check in timer
Timer1 event(..)
{
if ( ! bLoaded ) return;
.........Form has loaded now do rest ...
}
Hope this will help you,
you could get more frequent answers here
GOTDOTNET FORUM (http://gotdotnet.com/Community/MessageBoard/MessageBoard.aspx?ID=6)
Thanx
Paresh
rusky
January 24th, 2003, 11:46 AM
10x Paresh ! :)
That did it!
MartinL
January 25th, 2003, 07:34 AM
Originally posted by pareshgh
i.c,
You could use Timer control which does that for you.
and you could apply simple logic like this,
bool bLoaded = false;
which you will declare in class member.
on form load method
void Form1_Load(...)
{
..............do all control loading
bLoaded = true;
}
check in timer
Timer1 event(..)
{
if ( ! bLoaded ) return;
.........Form has loaded now do rest ...
}
Hope this will help you,
you could get more frequent answers here
GOTDOTNET FORUM (http://gotdotnet.com/Community/MessageBoard/MessageBoard.aspx?ID=6)
Thanx
Paresh
Just one question Paresh... Why there should be the timer? It looks like complicate solution for such a simple problem...
Why don't just call OnLoadFinished() method before Form_Load() method finishes?
Martin
pareshgh
January 25th, 2003, 09:17 PM
Hi Martin,
Why there should be the timer?
Since original problem dealt with on loading + showing splash screen.
your point would be usefull only if its sequential process in terms
1) Load Form
2) execute events after that after ONFORMLOADED...
But what if form is loading lots of data and updating lots of GUI and stuffs like that so that while loading they can show splash screen which can be updated in timer which equivalent to showing progress bar ! isn't it ?
your point is true since before loading SPLASH can be shown.
So its not a question of complicating.
Paresh
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.