CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2003
    Posts
    10

    Delay method in C#

    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...

  2. #2
    Join Date
    Dec 2002
    Location
    Sioux Falls, SD, USA
    Posts
    40
    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.
    Do what thou wilt, shall be the whole of the law.

  3. #3
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    if you just want to sleep then no need to create even thread object.

    Thread.Sleep(...)

    sleep for you while you think


    Paresh

  4. #4
    Join Date
    Jan 2003
    Posts
    10
    thanks guys!

  5. #5
    Join Date
    Jan 2003
    Posts
    10
    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..

  6. #6
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    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


    Thanx
    Paresh

  7. #7
    Join Date
    Jan 2003
    Posts
    10
    10x Paresh !
    That did it!

  8. #8
    Join Date
    Dec 2000
    Location
    Slovakia
    Posts
    1,043
    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


    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

  9. #9
    Join Date
    Nov 2002
    Location
    Singapore
    Posts
    1,890
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured