Получение System.ArgumentException - использование значения ключевого слова undefined 1 для события TaskScheduled в async apis.
Что-то не так, когда вы запускаете первый запрос ожидания в универсальном приложении с обновлением версии 5.0 для Visual Studio.
Я использую приложения WP8.1 Universal и silverlight после установки обновления Visual Studio 2013 3.
Исключения происходят в режимах эмулятора/устройства. Я провел пару дней, исследуя эту проблему без какого-либо разрешения.
У меня есть статья для брата на форуме Windows Dev, но я не слышал никаких ответов от Microsoft.
Код прямолинейный. Как только внутреннее исключение выбрано, ожидание никогда не вернется.
Есть ли у кого-нибудь другие проблемы с async?? разрешение?
public async Task<StorageFolder> FolderExists(StorageFolder parent, string folderName)
{
StorageFolder result = null;
try
{
// Exception happens here. The code never returns so the thread hangs
result = await parent.GetFolderAsync(folderName);
}
catch (Exception ex)
{
if (FeishLogger.Logger.IsDebug)
ex.LogException(() => string.Format("FolderExists File: {0}\\{1}", parent.Path, folderName));
}
return result;
}
Полное исключение:
System.ArgumentException occurred
_HResult=-2147024809
_message=Use of undefined keyword value 1 for event TaskScheduled.
HResult=-2147024809
IsTransient=false
Message=Use of undefined keyword value 1 for event TaskScheduled.
Source=mscorlib
StackTrace:
at System.Diagnostics.Tracing.ManifestBuilder.GetKeywords(UInt64 keywords, String eventName)
InnerException:
У меня есть образец проекта. Создание оболочки Universal App и добавление некоторого ожидания приведет к повторной проблеме.
private async Task AsyncMethod()
{
Debug.WriteLine("({0:0000} - Sync Debug)", Environment.CurrentManagedThreadId);
// Uncomment this line to make it work
//await Task.Delay(1);
// Fails only if the line above is commented
await Task.Run(() => Debug.WriteLine("({0:0000} - Async Debug)", Environment.CurrentManagedThreadId));
}
Вот полный код OnLaunched с вызовами AsyncMethod
protected override async void OnLaunched(LaunchActivatedEventArgs e)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = true;
}
#endif
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
// TODO: change this value to a cache size that is appropriate for your application
rootFrame.CacheSize = 1;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
// TODO: Load state from previously suspended application
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
#if WINDOWS_PHONE_APP
// Removes the turnstile navigation for startup.
if (rootFrame.ContentTransitions != null)
{
this.transitions = new TransitionCollection();
foreach (var c in rootFrame.ContentTransitions)
{
this.transitions.Add(c);
}
}
rootFrame.ContentTransitions = null;
rootFrame.Navigated += this.RootFrame_FirstNavigated;
#endif
await AsyncMethod();
await AsyncMethods();
await AsyncMethods();
await AsyncMethods();
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
if (!rootFrame.Navigate(typeof(MainPage), e.Arguments))
{
throw new Exception("Failed to create initial page");
}
}
// Ensure the current window is active
Window.Current.Activate();
}