Tag: C++/WinRT

Wait for IAsyncAction on STA thread

Figured out how to elegantly do a blocking wait for an asynchronous coroutine-enabled function on a STA thread. You can’t do this: There is an assertion failure because .get() assumes ability to block. On STA this hits a failure in winrt::impl::blocking_suspend call. So you have to avoid doing .get() to synchronize and there should be…

Read the full article

Windows 10 SDK RTWorkQ.h and C++/WinRT winrt::implements

Interface methods lack pure specifiers. This might be OK for some development but once you try to inherit your handler class from public winrt::implements<AsyncCallback, IRtwqAsyncCallback> you are in trouble! 1>Foo.obj : error LNK2001: unresolved external symbol “public: virtual long __cdecl IRtwqAsyncCallback::GetParameters(unsigned long *,unsigned long *)” (?GetParameters@IRtwqAsyncCallback@@UEAAJPEAK0@Z) 1>Foo.obj : error LNK2001: unresolved external symbol “public: virtual…

Read the full article

Windows 10 SDK 10.0.19041 needs some massaging

In: Out: 1>—— Build started: Project: CppWinrt01, Configuration: Debug x64 ——1>CppWinrt01.cpp1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\cppwinrt\winrt\impl\Windows.Foundation.0.h(983,26): error C2039: ‘wait_for’: is not a member of ‘winrt::impl’1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\cppwinrt\winrt\impl\Windows.Foundation.0.h(103): message : see declaration of ‘winrt::impl’1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\cppwinrt\winrt\impl\Windows.Foundation.0.h(985): message : see reference to class template instantiation ‘winrt::impl::consume_Windows_Foundation_IAsyncAction’ being compiled1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\cppwinrt\winrt\impl\Windows.Foundation.0.h(1004,26): error C2039: ‘wait_for’: is not a…

Read the full article

1 GB limit for Windows::Storage::FileIO::ReadLinesAsync?

There seem to be a limit of 1GB for FileIO::ReadLinesAsync API even though documentation is silent on this. The exception message itself adds no clarity: WinRT originate error – 0x80070057 : ‘The parameter is incorrect.’. The function starts working well when the input file is slightly reduced in size (under 1050 MB).

C++/WinRT version of SetFileTime

SetFileTime is simple and does not deserve a blog post: you have a file handle, you have date/time, you set it. C++/WinRT and UWP make the journey much more exciting. There is StorageItemContentProperties Class which provides access to the content-related properties of an item (like a file or folder). This includes file times which are…

Read the full article

Another API exception which should not have been thrown

From the documentation on StorageFolder.TryGetItemAsync(String) Method: Tries to get the file or folder with the specified name from the current folder. Returns null instead of raising a FileNotFoundException if the specified file or folder is not found. Exception thrown at 0x00007FFB06BDA799 (KernelBase.dll) in DownloadIssue.exe: WinRT originate error – 0x80070002 : ‘An item cannot be found with the specified name…

Read the full article