winrt-async

Possible solution to issue with multiple UI dispatchers in the same method?

别说谁变了你拦得住时间么 提交于 2019-12-25 04:30:12
问题 I'm having a problem with using multiple UI dispatchers to modify an list that is bound to the UI. The method with just exit when it hits the first dispatcher. If I wrap the entire method in the dispatcher it works, but I have another solution but I'm not sure it's appropriate: Basically, I have a socket listening in a never-ending loop for network commands from a media device. When it finds one, it calls ProcessCommand. That function calls one of 50+ methods to process the specific commands.

WinRT: DataReader.LoadAsync Exception with StreamSocket TCP

ぐ巨炮叔叔 提交于 2019-12-22 06:49:46
问题 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 get the following exception: "Operation identifier is not valid" This is the code of the method: private async void read() { while (true) { uint bytesRead = 0; try { bytesRead = await reader.LoadAsync(receiveBufferSize); if (bytesRead == 0) {

Porting CreateThread calls to Win8 / WinRT App

霸气de小男生 提交于 2019-12-13 18:14:36
问题 I need to call a C++ library from my C# Win8/WinRT app. The library is multithreaded and manages threads through calls to the Win32 API ( WaitForSingleObject , etc.). I was able to figure out the replacements for all these calls (there is always a ...Ex version available for Apps, e.g. WaitForSingleObjectEx from <synchapi.h> see there if you're looking for it). But there is one call I cannot figure out how to replace: it is a call to the CreateThread function. There is no equivalent, so it

Stop YouTube Video on Back Button of Windows Metro App 8.1

纵饮孤独 提交于 2019-12-13 07:09:34
问题 I have a page on which i am showing multiple youtube videos as webviews. When i play any video, then correspoding video starts playing. But When I click on the back button of the App i should be stop then but its running in background(can hear voice of video). here is the code of back button: protected void GoBack(object sender, RoutedEventArgs e) { ((Frame)Window.Current.Content).GoBack(); } Tell me how i can dispose of this webview or can stop video. Thanks 回答1: First make sure that the

BackgroundDownloader only downloading 5 at once

假装没事ソ 提交于 2019-12-13 04:31:57
问题 I create 1,000 downloads using BackgroundDownloader.CreateDownload , then I queue up 100 of them by doing DownloadOperation.Start . If I watch the traffic in fiddler, only 5 of them at actually send out at once. When one finishes, another is sent out. Is there a way to have more sent out concurrently? 回答1: Yes, there is a limit of 5 downloads at a time within Windows.Networking.BackgroundTransfer . You can extend it to up to 6 downloads at a time if you mark all your downloads as High

Are there any class in WinRT as MarketPlaceReviewTask in WP?

蹲街弑〆低调 提交于 2019-12-13 02:47:53
问题 Are there any class in WinRT as MarketPlaceReview or MarketPlaceSearch Tasks in WP? Thanks. 回答1: You can use Windows Store's protocol with specific arguments to launch several tasks related to Store like If you want to open review page for any app then, you can open with this line. await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store:REVIEW?PFN=MY_PACKAGE_FAMILY_NAME")); If you open the page of particular app in Store app then you can open with this line. await Windows

How to use Task.Delay to control time spans between calls to a web service

♀尐吖头ヾ 提交于 2019-12-11 15:08:41
问题 When a user takes a certain action a call (get) to a web service is made. The service doesn't allow for calls more frequent than once per second. I was thinking I could use Task.Delay to control this so that subsequent calls are made at least one second apart in time but it doesn't seem to work as expected. The pseudo-code looks like this: public async void OnUserAction() { var timeUntilPreviousCallWillBeOrWasMade = 1000ms - (Now - previousWaitStartTime); var

how to disable caching HTTP GET in metro app, I am using IXMLHTTPRequest2

六眼飞鱼酱① 提交于 2019-12-10 18:10:18
问题 I am doing an http GET to fetch data, I am using IXMLHTTPRequest2. If I GET url "http://foo.com" (curl "http://foo.com"), the second time I get this url again, the content on server is actually changed, but what I am getting is the cached result. Caching seems only honor URL, so if different header with same URL, still same cached result. I have tried "Cache-Control: no-cache", "Cache Control: no-store", and "Pragma: no-cache". None of them are honored by the API. Is there a way to turn cache

Why does HttpClient appear to deadlock here?

时光总嘲笑我的痴心妄想 提交于 2019-12-08 07:06:58
问题 I have an API made in a portable class library which needs to reach out to platform specific APIs for sending HTTP requests. Here is the method I wrote to do an HTTP POST on WinRT: public bool Post(IEnumerable<KeyValuePair<string, string>> headers, string data) { bool success = false; HttpClient client = new HttpClient(new HttpClientHandler {AllowAutoRedirect = false}); foreach (var header in headers) { client.DefaultRequestHeaders.Add(header.Key, header.Value); } try { var task=client

Task caching when performing Tasks in parallel with WhenAll

落花浮王杯 提交于 2019-12-07 08:15:11
问题 So I have this small code block that will perform several Tasks in parallel. // no wrapping in Task, it is async var activityList = await dataService.GetActivitiesAsync(); // Select a good enough tuple var results = (from activity in activityList select new { Activity = activity, AthleteTask = dataService.GetAthleteAsync(activity.AthleteID) }).ToList(); // begin enumeration // Wait for them to finish, ie relinquish control of the thread await Task.WhenAll(results.Select(t => t.AthleteTask));