Winforms, handling simultaneous events, async/await or Task.Run()

84 Views Asked by At

I'm developing a Net6 Windows Form application This application is connected with SignalR to a server, and server send message to it. Moreover the application monitors some folders with FileSystemWatcher.

Application waits and when events occur (signalR or when a file is created) the dedicated methods are executed. These methods for example write records to a database or call web apis, wait for response and write other files. Nothing of expensive for CPU.

The form UI is very poor, there are few controls, just a few buttons and a textbox connected to serilog, so it is not important to update the UI.

All methods called by signalr events or FileSystemWather events are async/await.

I wonder what happens if multiple events happen at the same time or almost let's say (also from different sources, signalr calls or filesystemwatcher). Do each event runs in a separate task or there might be problems handling concurrent events? I have to manage the events methods with Task.Run() or is it's enough the async/await ?

Thank you very much

Andrea

0

There are 0 best solutions below