Как установить приоритет события клика в первую очередь ⇐ C#
-
Anonymous
Как установить приоритет события клика в первую очередь
I'm doing the cancel uploading if it too long, i decided to use a splashscreen with cancel button
When i click the cancel button, the cancel() of cancellation request will be call, but everytime i try, the click event always fire after the request done and i also received the response. How to overcome this problem?
private async void CancelUpload_OnClick(object sender, RoutedEventArgs e) { //App.CurrentWindow.TokenSource.Cancel(); App.CurrentWindow.cancelAction?.Invoke(); } I try to use Action end Invoke it, but there also no hope. Sample request i make:
App.CurrentWindow.cancelAction = () => { App.CurrentWindow.TokenSource.Cancel(); }; // var response = HttpClient.Instance.PostAsync(GetFileRequestUrl(), content, App.CurrentWindow.TokenSource.Token).Result; // App.CurrentWindow.TokenSource.Token.ThrowIfCancellationRequested();
Источник: https://stackoverflow.com/questions/781 ... vent-first
I'm doing the cancel uploading if it too long, i decided to use a splashscreen with cancel button
When i click the cancel button, the cancel() of cancellation request will be call, but everytime i try, the click event always fire after the request done and i also received the response. How to overcome this problem?
private async void CancelUpload_OnClick(object sender, RoutedEventArgs e) { //App.CurrentWindow.TokenSource.Cancel(); App.CurrentWindow.cancelAction?.Invoke(); } I try to use Action end Invoke it, but there also no hope. Sample request i make:
App.CurrentWindow.cancelAction = () => { App.CurrentWindow.TokenSource.Cancel(); }; // var response = HttpClient.Instance.PostAsync(GetFileRequestUrl(), content, App.CurrentWindow.TokenSource.Token).Result; // App.CurrentWindow.TokenSource.Token.ThrowIfCancellationRequested();
Источник: https://stackoverflow.com/questions/781 ... vent-first
Мобильная версия