Can someone explain what is Application.DoEvents()
hi,
i'm new to vb.net..
right now i have to deal with vb.net program n came accross some method which is called Application.DoEvents()..
i have no idea on how this thing works..
i had googled n find some article at msdn n try to understand it with the source code but it seem that i still confused on how to deal with this thing..
what is actual this method do..
some said that it also represent thread.sleep..
hope some do help me in this matter..
thanks in advanced
Re: Can someone explain what is Application.DoEvents()
It's not related to Thread.Sleep at all. Your application's main thread can only do one thing at a time, so if it is busy running one of your methods and an event is raised, e.g. a Button.Click or a Timer.Tick, then that event will have to wait until the main thread is finished running your method before it can be handled. By calling Application.DoEvents you are telling the application to go ahead and handle any pending events before continuing on with the current method.
This is the poor man's way of making the UI appear responsive to the user while the code is performing some long-running operation. I say that because it has serious limitations and it is also very inefficient to keep calling it if there are no pending events.
Re: Can someone explain what is Application.DoEvents()
thanks dude..
now i understood..:thumb:
so do have any other idea beside using application.doevents() method to continue an event?
Re: Can someone explain what is Application.DoEvents()
If you want the UI to remain responsive during a long-running operation then the "proper" way is to perform that operation in a secondary thread.
If you were to provide an explanation of what you're actually trying to achieve then we could provide specific information.
Re: Can someone explain what is Application.DoEvents()
i rite now developing a system for contact card which i have to retrieve data inside the contact card chip..
there are several applet install inside the chip..
currently i'm using two slots reader which i can only check up to two card.
When the checking process occurred, if the operator inside only one card so i have to display only one portion of my system which resemble only one slot is working.
If the operator use both the two slots so i have to provide them with two UI that work concurently.
Basiclly this two system is the same type of system that operator will use.
It is the duplication of the one slot system that operator had used before.
Re: Can someone explain what is Application.DoEvents()
A UI is a UI. If your app has two sections that look the same it is still just one UI. As with all UIs, they will freeze if you perform some long-running operation on the main thread. You could get away with calling Application.DoEvents in very simple situations but you really should look at multi-threading. The BackgroundWorker class might be the first place to look. If you follow the CodeBank link in my signature you'll find my submission on that topic.