Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Difference between Async and Sync events
#1
Hello!

I really need to know what the difference is between asynch and synch events!

For instance, I created a new application with only a TIWTimer on the form. Then I created a OnTimerEvent doing nothing.
When run the OnTimerEvent is fired as it should.
Now I added a OnAsynchTimer event to the same IWTimer.
When run now the OnAsynchTimer is fired but not the OnTimerEvent?

Another example:
New empty application with only a event defined for OnResize doing nothing.
When starting the application or resizing the browser window OnResize  is called as expected.
Now creating a OnAsyncResize event. Both OnResize and OnAsyncResize  are called on form creation and browser form resize.

Now I added a IWTimer to the last example and added a OnTimer event to it.
The OnTimerEvent fires as expected but also the forms OnAsyncResize event?!
If I remove the OnTimer event and instead add a OnAsyncTimer the OnAsyncTimer is triggerd as expected but there is no OnAsyncResize triggered.

Is there some documentation about this? I Googled but can't find any good explanation.

Best regards, Mikael
Reply
#2
Hi Mikael,

The difference between synchronous (sync) and asynchronous (async) events is related to how the events are processed by the application.

In synchronous events, the application will wait for the event to complete before moving on to the next task. This means that any other events or tasks that may be waiting in the queue will be put on hold until the synchronous event is completed. In your example, the OnTimerEvent is a synchronous event, so the application will wait for it to complete before moving on to any other events or tasks.

In contrast, asynchronous events do not hold up the application while they are being processed. Instead, they are executed independently of other events and tasks. This means that other events or tasks can be executed while the asynchronous event is being processed. In your example, the OnAsynchTimer and OnAsyncResize events are asynchronous, so they do not hold up the application while they are being processed.

It is important to note that the behavior of synchronous and asynchronous events can vary depending on the specific application and programming language being used. It is always best to consult the documentation or seek advice from an experienced developer if you are unsure about the behavior of a specific event or function.

I hope this helps clarify the difference between synchronous and asynchronous events for you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)