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

VB.NET event driven routines

  • 30-10-2011 2:22am
    #1
    Closed Accounts Posts: 1,155 ✭✭✭


    Hi all,

    Very quick question:

    In VB.NET, let's say I have one module that is kicked off by Button1.Click. I also have another module that is started by Timer1.Tick.

    Hypothetically, if the timer ticks at the exact same time as the button is pressed, will my modules run on different threads?

    Or do I need to code it to run multi-threaded?

    Thanks!


Comments

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


    Windows GUI is single threaded and uses a messaging system (WM_CLICK, WM_TIMER etc.), so the two events will never happen at the same time. The messages will be queued and one will happen before the other.

    Also if for instance the button click is queued first, and the timer is triggered second, the timer event will not run until the button event code completes. If your button click takes 10 seconds the UI will appear frozen until the event completes (unless you process windows messages as part of the event).

    HTH

    D.


  • Closed Accounts Posts: 1,155 ✭✭✭Stainless_Steel


    OK great thanks.

    So say if I had a timer with an interval of 2 seconds. If the code driven by the timers tick takes longer than 2 seconds what happens? Will I get a crash or will the next timer tick be ignored?


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


    Off the top of my head I'm not sure, nothing to test it on now, but I know it won't crash or the event re-fire (reentrant), I think the next tick will just be ignored.

    D.


Advertisement