It depends on the type of application and whether the event is risen in the same thread.
Let's assume that you have a WinForms application, that the code shown above is running from a Click
-event and that the PinChanged
event is triggered in the same thread, i.e. the UI-thread.
WinForms never interrupts your running code. If you have a long running Click method and the user is clicking a second time before the method is terminated, then the second click event is put into a wait queue and the first click method continues until it is terminated. This also means that the long running method is blocking the UI. On the other hand, it makes things much simpler, as you don't have to deal with code blocks interrupting each other or running at the same time, what could be very tricky.
The same is true for your PinChanged
event. It will only run Func5
when your application is idle, i.e. all other code is terminated.
Again, this is only true if you or the library functions involved do not use multithreading. It is unlikely that PinChanged
will be risen in another thread, unless the documentation explicitly states it.