-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why does AsyncOperationCompletedHandler::new require Send? #63
Comments
Short answer: I do not know. I think that I added the |
I was thinking a similar thing about whether it could be handled in async/await. I haven’t thought too hard about it yet. I can’t speak for other uses of it, but I can now speak for the For my particular case, I believe I need the let mut control = None;
let operation = process
.create_web_view_control_async(host_window_handle, rect)
.expect("CreateWebViewControlAsync call failed");
operation.set_completed(&AsyncOperationCompletedHandler::new(|_sender, _args| {
control = operation.get_results().unwrap();
if let Some(ref control) = control {
control.navigate(&Uri::create_uri(&FastHString::from("http://www.example.com")).unwrap()).unwrap();
}
})); |
We would really need to know if it's guaranteed that async operations always execute on the thread that created the callback. If it's not guaranteed, the By the way, I'm experimenting with async/await in a branch: https://github.com/Boddlnagg/winrt-rust/tree/futures-preview |
AsyncOperationCompletedHandler::new::<_F_>
includesSend
in its bounds for_F_
, and I’m not sure why it does, or whether it should in fact.For “I’m not sure why”:
AsyncOperationCompletedHandler
is explicitly marked!Send
and!Sync
, so why would its callback need to beSend
?For “I’m not sure whether it should”: my concrete use case is
WebViewControl
, which requires a single-threaded apartment anyway. Given thatWebViewControl
instantiation is done asynchronously and you can’t useblocking_get()
for reasons I won’t contemplate, theSend
bound on the callback is very debilitating; it actively blocks what seems to me the most likely way you want to use it.I have not investigated in any depth, but my intuition says that IAsyncOperation would always be at least effectively single-threaded.
Have I missed something? Is there a reason why that
Send
bound is there?The text was updated successfully, but these errors were encountered: