Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Putting a time delay in VB.net

  • 29-01-2007 8:43pm
    #1
    Registered Users, Registered Users 2 Posts: 1,055 ✭✭✭


    I want to delay the call of a procedure by a few seconds (3 seconds or so)


    Me.Show()


    'calls print procedures above
    CaptureScreen()
    prtDocument.Print()


    So after Me.Show () I want to put a few seconds delay in before it calls the CaptureScreen() procedure.

    Any idea how I could do this? Is it even possible?

    Thanks


Comments

  • Registered Users, Registered Users 2 Posts: 1,423 ✭✭✭Merrion




  • Registered Users, Registered Users 2 Posts: 2,152 ✭✭✭dazberry


    As Merrion said:
    System.Threading.Thread.Sleep(3000);

    The only catch is that that will completely freeze your application for the sleep duration. An alternative would be to use a timer (System.Timers.Timer). Example in C#.
    Timer T = new System.Timers.Timer(3000);
    T.AutoReset = false;           
    T.Elapsed += new ElapsedEventHandler(T_Elapsed);
    T.Enabled = true;
    
    // Event Handler
    void T_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
    {
     if (InvokeRequired)
          Invoke(new ElapsedEventHandler(T_Elapsed),sender,e);
     else
          CaptureScreen();
    }
    
    You might not need the invoke but I put it in there for completeness.

    HTH

    D.


Advertisement