简体   繁体   English

如何防止保存数据导致Windows Phone死锁?

[英]How to prevent saving data from causing deadlock in windows phone?

i've a function which insert in the database async. 我有一个异步插入数据库的功能。 , that function is call at background transfer status changed and sometime it causing deadlock ,该函数在后台传输状态更改时被调用,并且有时会导致死锁

    await vm.InsertVerseDownloadProgress_Bulk(tracks.Cast<QuranVerseTrack>().ToList()).ConfigureAwait(true);

    await vm.InsertVerseDownloadProgress_Bulk(tracks.Cast<QuranVerseTrack>().ToList()).ConfigureAwait(false);

    await vm.InsertVerseDownloadProgress_Bulk(tracks.Cast<QuranVerseTrack>().ToList()).ConfigureAwait(true);

i'm not sure which one to use 我不确定要使用哪个

ConfigureAwait(true) is the default and causes your Task to marshal back to the thread it was started at. 默认情况下,ConfigureAwait(true)会导致您的Task编组回其开始所在的线程。

The deadlock is mostly caused by waiting on the result somewhere in the UI tread (wait, not await; by calling task.wait or task.result). 死锁主要是由于在UI界面某个位置上等待结果而导致的(等待,不是等待;通过调用task.wait或task.result)。

Your question cannot be answered without further context. 没有进一步的上下文,您的问题将无法回答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM