winrt-async

How to properly wait for asynchronous WinRT callback functions to stop?

一曲冷凌霜 提交于 2020-01-25 21:52:08
问题 I asked a similar question before but the answer there did not satisfy my requirement. Let me explain. I call the following code from a DLL to perform a WinRT operation on Windows 10 from a Windows Store app. The code uses WRL: #include <Windows.Services.Store.h> #include <wrl.h> auto onAppLicCompletedCallback = Callback<Implements<RuntimeClassFlags<ClassicCom>, IAsyncOperationCompletedHandler<StoreAppLicense*>, FtmBase>>( [](IAsyncOperation<StoreAppLicense*>* operation, AsyncStatus status) {

When does a PPL task execute on the UI thread?

感情迁移 提交于 2020-01-16 04:14:08
问题 When calling create_task is there a way to ensure that the task doesn't run on the UI thread? I want to be sure I'm not inadvertently calling wait inside a task that somehow managed to execute on the UI thread. 回答1: The create_task function won't spontaneously jump onto the UI thread: if you don't call it from the UI thread it won't execute there. You need to explicitly call the Dispatcher to get back. An apartment aware task (one which returns IAsyncAction or IAsyncOperation) will continue

Delphi - Making asynchronous calls to WinRT API using TTask.Future

丶灬走出姿态 提交于 2020-01-14 04:23:10
问题 Related to this question, I am trying to implement a procedure that uses the WinRT API to set the desktop wallpaper. To mimic the await functionality in C#, I am using TTask.Future (link) as outlined here and here. My implementation looks like this: class procedure TUtilityWin.SetWallpaper(AFileName: String); var lStorageFile: IStorageFile; liao_storagefile: IAsyncOperation_1__IStorageFile; lFutureTask: IFuture<IAsyncOperation_1__IStorageFile>; begin //WinRT Implementation if TUserProfile

Saved files sometime only contains NUL-characters

北城以北 提交于 2020-01-01 05:22:07
问题 We have a problem in our Windows 8.1 application (WinRT) that sometimes our saved file gets corrupt. The files have a correct file size, but the file only contains NUL-characters. The file should contain a serialized object as XML. In an attempt to find the issue we do not overwrite the file, we do the following: Serialize the current object to a temp file. Check the content of the temp file Copy the current file (to .timestamp.xml.bak) Move/replace the temp file to the current file Most of

How to wait for an IAsyncAction?

我的梦境 提交于 2019-12-30 06:02:11
问题 In Windows Store Apps, C++(C# is similar though), doing something like IAsyncAction^ Action = CurrentAppSimulator::ReloadSimulatorAsync(proxyFile); create_task( Action ).then([this]() { }.wait(); results in an unhandled exception. Usually it's Microsoft C++ exception: Concurrency::invalid_operation at memory location 0x0531eb58 And I kind of need for that action to finish to get my In App Purchase information before trying to use it. The weird thing here is that anything else besides

How to wait for an IAsyncAction?

只谈情不闲聊 提交于 2019-12-30 06:02:06
问题 In Windows Store Apps, C++(C# is similar though), doing something like IAsyncAction^ Action = CurrentAppSimulator::ReloadSimulatorAsync(proxyFile); create_task( Action ).then([this]() { }.wait(); results in an unhandled exception. Usually it's Microsoft C++ exception: Concurrency::invalid_operation at memory location 0x0531eb58 And I kind of need for that action to finish to get my In App Purchase information before trying to use it. The weird thing here is that anything else besides

Windows 8.1 App - HttpWebRequest working only once

扶醉桌前 提交于 2019-12-25 12:20:30
问题 I've a problem with my simple windows store app. I'm connecting to SharePoint and query his REST services to get the information I need. Actually I'd like to create a sort of "SharePoint Browser" so that a user can navigate the List structure of SharePoint browsing with the APP. Actually I get the security token from SharePoint and use it in all the calls without any problem. My call is something like: var bldr = new UriBuilder(_uri.ToString()); bldr.Path += _listDataSvc + (String

In UWP StreamSocket, can I read data with timeout and leave the connection open if timeout elapses

回眸只為那壹抹淺笑 提交于 2019-12-25 09:05:54
问题 As I couldn't find any way to peek for data (read data without consuming the buffer) as asked at How to peek StreamSocket for data in UWP apps I'm now trying to make my own "peek" but still no luck. I don't see how I can read data from StreamSocket in the manner which will let me use timeouts and leave the connection usable in case if timeout elapses. In the end, the problem is as follows. In my, let's say, IMAP client, I get response from a server and if this response is negative, I need to