[GH-ISSUE #210] Thread-safe #133

Closed
opened 2026-05-05 11:06:23 -06:00 by gitea-mirror · 5 comments
Owner

Originally created by @FilipoGuci on GitHub (Jun 18, 2020).
Original GitHub issue: https://github.com/qmlnet/qmlnet/issues/210

Hello, I am a beginner C # developer. I am interested in your qml.net library, please tell me if it’s not difficult for you. Since I cannot use Dispatcher, how can I handle the event safely? Thanks in advance.

Originally created by @FilipoGuci on GitHub (Jun 18, 2020). Original GitHub issue: https://github.com/qmlnet/qmlnet/issues/210 Hello, I am a beginner C # developer. I am interested in your qml.net library, please tell me if it’s not difficult for you. Since I cannot use Dispatcher, how can I handle the event safely? Thanks in advance.
Author
Owner

@pauldotknopf commented on GitHub (Jun 18, 2020):

Which event are you speaking of, specifically?

<!-- gh-comment-id:645837096 --> @pauldotknopf commented on GitHub (Jun 18, 2020): Which event are you speaking of, specifically?
Author
Owner

@FilipoGuci commented on GitHub (Jun 18, 2020):

For example, I have a library that sends, receives and decodes data, I create an event for decoding and subscribe to it in the main form, if you do not use the dispatcher, the form hangs

<!-- gh-comment-id:645844594 --> @FilipoGuci commented on GitHub (Jun 18, 2020): For example, I have a library that sends, receives and decodes data, I create an event for decoding and subscribe to it in the main form, if you do not use the dispatcher, the form hangs
Author
Owner

@pauldotknopf commented on GitHub (Jun 18, 2020):

I don't really know what you are asking. Can you provide a simple Program.Main with some explanation?

<!-- gh-comment-id:645845890 --> @pauldotknopf commented on GitHub (Jun 18, 2020): I don't really know what you are asking. Can you provide a simple ```Program.Main``` with some explanation?
Author
Owner

@FilipoGuci commented on GitHub (Jun 18, 2020):

lib.dll
public event EventHandler OnVersion;
public async Task Version()
{
//some actions
OnVersion?.Invoke(this, version);
}
Program.cs
uDP.OnVersion += UDP_OnVersion;
private void UDP_OnVersion(object sender, SomeEventsArgs e)
{
displayResult = $"Firmware version: {e.Version}"
}

<!-- gh-comment-id:645851021 --> @FilipoGuci commented on GitHub (Jun 18, 2020): lib.dll public event EventHandler<SomeEventsArgs> OnVersion; public async Task<SomeEventsArgs> Version() { //some actions OnVersion?.Invoke(this, version); } Program.cs uDP.OnVersion += UDP_OnVersion; private void UDP_OnVersion(object sender, SomeEventsArgs e) { displayResult = $"Firmware version: {e.Version}" }
Author
Owner

@pauldotknopf commented on GitHub (Jun 18, 2020):

On the UDP_OnVersion, you must dispatch the data back to the UI thread with QCoreApplication.Dispatch.

<!-- gh-comment-id:646246982 --> @pauldotknopf commented on GitHub (Jun 18, 2020): On the UDP_OnVersion, you must dispatch the data back to the UI thread with ```QCoreApplication.Dispatch```.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/qmlnet#133
No description provided.