C# 任务的数量有限制吗?

C# 任务的数量有限制吗?,c#,windows-runtime,task,C#,Windows Runtime,Task,我正在运行一个包含多个任务的winrt程序。 在运行过程中,我得到以下异常: Not enough quota is available to process this command 堆栈跟踪为 at Windows.UI.Core.CoreDispatcher.InvokeAsync(CoreDispatcherPriority priority, InvokedHandler freeThreadedCallback, Object sender, Object context)

我正在运行一个包含多个任务的winrt程序。 在运行过程中,我得到以下异常:

Not enough quota is available to process this command
堆栈跟踪为

   at Windows.UI.Core.CoreDispatcher.InvokeAsync(CoreDispatcherPriority priority, InvokedHandler freeThreadedCallback, Object sender, Object context)
   at System.Threading.WinRTSynchronizationContext.Post(SendOrPostCallback d, Object state)
   at System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.InvokeOrPostAction(Object state)
   at System.Threading.Tasks.AwaitTaskContinuation.RunInline(ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
   at System.Threading.Tasks.AwaitTaskContinuation.<ThrowAsyncIfNecessary>b__1(Object s)
   at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
在Windows.UI.Core.CoreDispatcher.InvokeAsync(CoreDispatcherPriority,InvokedHandler freeThreadedCallback,对象发送方,对象上下文)
位于System.Threading.WinRTSynchronizationContext.Post(SendorPostd,对象状态)
位于System.Threading.Tasks.SynchronizationContextAwaitTaskContinuation.InvokeOrpStation(对象状态)
位于System.Threading.Tasks.AwaitTaskContinuation.RunInline(ContextCallback回调,对象状态)
---来自引发异常的上一个位置的堆栈结束跟踪---
在System.Threading.Tasks.AwaitTaskContinuation.b__1(对象s)中
位于System.Threading.QueueUserWorkItemCallback.WaitCallback_上下文(对象状态)
位于System.Threading.ExecutionContext.RunInternal(ExecutionContext ExecutionContext、ContextCallback回调、对象状态、布尔值preserveSyncCtx)
在System.Threading.ExecutionContext.Run(ExecutionContext ExecutionContext,ContextCallback回调,对象状态,布尔保存SyncCTX)
位于System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()处
在System.Threading.ThreadPoolWorkQueue.Dispatch()中
在System.Threading.\u ThreadPoolWaitCallback.PerformWaitCallback()中
然后它崩溃了

这是WintRT特有的问题吗

有解决方法吗?

根据,该错误的修复方法是“关闭一些应用程序”或“增加分页文件的大小”


考虑到这一点,您可能希望从查看任务管理器开始,看看您的应用程序是否使用了完全不合理的内存量(或者是否有其他进程)。如果进程内存泄漏,则可能导致此问题。

是否共享一些代码?我相信,通过在调试模式下运行应用程序,您可以看到异常发生的位置—请记住.Net任务是在同步上下文上运行的。在您的例子中,同步上下文是UI线程(您看到这一点是因为它正在调用CoreDispatcher.InvokeAsync)。这意味着您的所有任务都将在UI线程上连续运行。那是你的本意吗?