Questions tagged [winrt-async]

This is a tag for Windows Runtime's introduced with Windows 8 for Windows Store (previously called "Metro Style") Apps. Async calls allow you to call a method without having to wait for it's response, and thus allowing you to call a method and not have the whole application freeze while its waiting for a response.

231 questions
29
votes
2 answers

Async implementation of IValueConverter

I have an asynchronous method which I want to trigger inside an IValueConverter. Is there a better way than forcing it to be synchronous by calling the Result property? public async Task Convert(object value, Type targetType, object…
Boas Enkler
  • 12,264
  • 16
  • 69
  • 143
25
votes
4 answers

A method was called at an unexpected time

I'm trying to iterate all files in a directory using GetFilesAsync, but every time I call the GetResults method, it throws an exception that says System.InvalidOperationException: A method was called at an unexpected time The code is simply var…
XSL
  • 2,965
  • 7
  • 38
  • 61
24
votes
2 answers

Correct way to call async methods from within a data-bound property setter?

Now I know properties do not support async/await for good reasons. But sometimes you need to kick off some additional background processing from a property setter - a good example is data binding in a MVVM scenario. In my case, I have a property…
Bernhard Koenig
  • 1,342
  • 13
  • 23
20
votes
3 answers

How to await a method in a Linq query

Trying to use the await keyword in a LINQ query and I get this: The 'await' operator may only be used in a query expression within the first collection expression of the initial 'from' clause or within the collection expression of a 'join'…
c0D3l0g1c
  • 3,020
  • 5
  • 33
  • 71
17
votes
3 answers

HttpClient: Conditionally set AcceptEncoding compression at runtime

We are trying to implement user-determined (on a settings screen) optional gzip compression in our client which uses HttpClient, so we can log and compare performance across a number of different calls over a period of time. Our first attempt was to…
pcdev
  • 2,852
  • 2
  • 23
  • 39
14
votes
4 answers

How to wait for an IAsyncAction?

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…
RelativeGames
  • 1,593
  • 2
  • 18
  • 27
12
votes
5 answers

How do I send an email from a WinRT/Windows Store application?

I am developing a Windows Store Application (Windows 8). I have a need to send emails based on data and address stored in the application data and without the need of the user to type it the data or the address. What would be the right/easy way to…
user1211925
11
votes
3 answers

Json.net Async when writing to File

Json.net has the async functions for converting an object to json like: json = await JsonConvert.DeserializeObjectAsync But when I want to write an object to a json file it seems better to me to do it directly using a file Stream. So i think it…
Boas Enkler
  • 12,264
  • 16
  • 69
  • 143
10
votes
2 answers

Why does the use of StreamSocket in a loop cause a memory leak?

I'm developing a C#, UWP 10 solution that communicates with a network device using a fast, continual read/write loop. The StreamSocket offered by the API seemed to work great, until I realized that there was a memory leak: there is an accumulation…
BCA
  • 7,776
  • 3
  • 38
  • 53
9
votes
1 answer

Saved files sometime only contains NUL-characters

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…
Bojo
  • 381
  • 1
  • 5
  • 16
8
votes
3 answers

How to get file size in WinRT?

In WinRT there is no FileInfo class, only a StorageFile class. How can I get the size of a file using the StorageFile class?
Yang
  • 825
  • 1
  • 10
  • 13
7
votes
4 answers

Copy Folder on WinRT

For now, I just know how to copy file using: IStorageFolder dir = Windows.Storage.ApplicationData.Current.LocalFolder; IStorageFile file = await StorageFile.GetFileFromApplicationUriAsync( new Uri("ms-appx:///file.txt")); await…
Crazenezz
  • 3,416
  • 6
  • 31
  • 59
7
votes
2 answers

Cancel a static async function with a timeout

I need to cancel the UpdateDatabase() function if it takes more than 2 minutes. I 've tried cancellationtokens and timers but I couldn't manage to solve this (couldn't find any appropriate example). Could you please help me on…
Korki Korkig
  • 2,736
  • 9
  • 34
  • 51
5
votes
1 answer

Metro App FileIO.WriteTextAsync Multiple Threads

I have a method which is called frequently from multiple threads. It involves writing to disk using await FileIO.WriteTextAsync. This works fine when it is called from a single thread, but once I start doing this in multiple threads, I get this…
c0D3l0g1c
  • 3,020
  • 5
  • 33
  • 71
5
votes
2 answers

WinRT: DataReader.LoadAsync Exception with StreamSocket TCP

I'm programming a client app on WinRT in C# which connects to several servers by TCP. For the TCP connection I use StreamSocket. The Input and Output Strings are then wrapped in a DataWriter and a DataReader. When I connect to more than one server I…
mentras
  • 131
  • 1
  • 7
1
2 3
15 16