Results 1 to 5 of 5

Thread: [RESOLVED] [2005] Interrupt sleep

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    910

    Resolved [RESOLVED] [2005] Interrupt sleep

    Hi,
    I have my program sleeping with System.Threading.Thread.Sleep(1800000) which makes it pretty much just stop for 10 minutes. How can I interrupt this if needed though? And if I can't interrupt it, what's a better way to do this?
    Thanks!

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [2005] Interrupt sleep

    Use the .Interrupt()
    method but it only applies to threads in the WaitSleepJoin thread state.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    413

    Re: [2005] Interrupt sleep

    Use a loop

    VB Code:
    1. Do while checkbox.checked = true
    2.    threading.thread.sleep(250)
    3.    application.doevents()
    4. loop
    Last edited by PENNYSTOCK; Aug 28th, 2006 at 02:29 PM.
    Visual Studio .NET 2005/.NET Framework 2.0

  4. #4
    Hyperactive Member
    Join Date
    Mar 2006
    Posts
    413

    Re: [2005] Interrupt sleep

    Why do you want it to sleep. If this is the main thread, then your app would will not respond at all. I'd use a timer if you want to do something every so often.
    Visual Studio .NET 2005/.NET Framework 2.0

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    910

    Re: [2005] Interrupt sleep

    I may look into the timer option. Thanks for the replies guys.

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