winrt-notification icon indicating copy to clipboard operation
winrt-notification copied to clipboard

Purpose of sleep

Open Immortalin opened this issue 3 years ago • 3 comments

What is the purpose of https://github.com/allenbenz/winrt-notification/blob/f7879fd06615cb62692469966edf28326639d7dc/src/lib.rs#L335?

Is the toast notification function not blocking?

Immortalin avatar Jan 19 '22 20:01 Immortalin

There's a race where if the application closes before some part of the internal toast process (non-application layer) completes the toast won't get shown. The window is small and the 10ms wait satisfies the race condition.

So in a long running program this isn't required. Though Toasts are rate limited so the wait shouldn't be too big of an issue for most applications.

You can reproduce the issue by running the tests/examples with the sleep removed, the toast will sometimes not appear (or never appear)

allenbenz avatar Jan 26 '22 19:01 allenbenz

Shouldn't it return a Future<Result> then? The caller can choose whether they want to block on the thread.

Immortalin avatar Jan 26 '22 21:01 Immortalin

Probably useful to add an inline note about that for anyone else curious about that line :sweat_smile:

polarathene avatar Jan 27 '22 20:01 polarathene