Getting System.ArgumentException - Utilizzo del valore di parola chiave non definito 1 per l'evento TaskScheduled in asis asincroni.ArgumentException - Utilizzo del valore di parola chiave non definito 1 per l'evento TaskScheduled in async
C'è qualcosa che non va quando si esegue la prima istruzione attendono in un app universale con Visual Studio 2013 Aggiornamento 3.
Sto usando WP8.1 universale e applicazioni Silverlight dopo aver installato Visual Studio 2013 Aggiornamento 3.
Le eccezioni si verificano nelle modalità Emulatore/Dispositivo. Ho trascorso un paio di giorni a cercare questo problema senza alcuna soluzione.
Ho un articolo di pari livello nel forum di Windows Dev Center ma non ho ricevuto alcuna risposta da Microsoft.
Il codice è semplice. Una volta generata l'eccezione interna, l'attesa non ritorna mai.
Qualcun altro ha questi problemi con async ?? risoluzione?
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;
}
eccezione completa:
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:
Ho un progetto di esempio disponibili. La creazione di un'app universale per shell e l'aggiunta di alcune istruzioni di attesa rendono il problema rielaborato.
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));
}
Ecco il codice OnLaunched completo con le chiamate a 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();
}
Ho rimosso e reinstallato gli SDK di Windows Phone, gli emulatori e Visual Studio. Dopo aver reinstallato tutto il problema persiste !! per favore aiuto –
Ho riscontrato lo stesso problema - hai risolto? –
C'è un buco nel forum MSDN: [Hack workaround finché Microsoft non lo risolve] (http://social.msdn.microsoft.com/Forum/windowsapps/it-IT/3e505e04-7f30-4313-aa47-275eaef333dd/systemargumentexception-uso-di-undefined-parola chiave-valore-1-per-evento-taskscheduled-in-async? forum = wpdevelop) –