task

Task.Run doesn't execute [closed]

点点圈 提交于 2020-04-17 21:58:43
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 9 days ago . My 64bit application uses Tasks a lot and now I appear to have a situation in which Task.Run isn't executed. The ThreadPool has 32768 threads AFAIK and I cannot imagine that all of these are used. What could prevent Task.Run from executing? And how can I diagnose the problem? UPDATE Before reading

Task has a wrong return type

点点圈 提交于 2020-04-16 03:49:11
问题 What wrong? and how to fix??I'm trying to learn a new subject in c#-task. and when I run I got error message: Error CS0407 'Task MainWindow.btn1_ClickAsync(object, RoutedEventArgs)' has the wrong return type public async Task btn1_ClickAsync(object sender, RoutedEventArgs e) { txtState.Text = "btn1_Click started"; await LongRunningFunc1(); txtState.Text = "btn1_Click finished"; } private async Task LongRunningFunc1() { txt1.Text = "Processing 1 ....."; btn1.Content = "Wait"; await Task.Delay

Nested Async Await Does not Wait

随声附和 提交于 2020-04-13 05:43:11
问题 I think I missunderstanding the behaviour of async await in c#. I have two methods that return a Task defined like public async Task Name() { await AsyncOperation() } Imagine AsyncOperation() like an PostAsync of HttpClient . Now I call them inside some other methods public asyn Task Method() { await Name1(() => { "bla bla"}); await Name2(); Console.WriteLine("Continue"); } This works as expected to me. Waits until Name1() and Name2() finish and then continues. Now I need to nest Name1() and

TPL cancellation continuation never called on cancelled Task

我只是一个虾纸丫 提交于 2020-04-12 20:51:36
问题 I have the following setup in my code that utilizes the TPL: One field in my class: private CancellationTokenSource _cancellationTokenSource; This CancellationTokeSource gets instatiated every time I create a TPL task that uses that particular cancellationtoken The actualy TPL tasks look like this: var dataRetrievalTask = new Task<List<myType>>(() => { // retrieve data and do something foreach (var a in retrievalMethod()) { if (_cancellationTokenSource.Token.IsCancellationRequested)

TPL cancellation continuation never called on cancelled Task

十年热恋 提交于 2020-04-12 20:43:31
问题 I have the following setup in my code that utilizes the TPL: One field in my class: private CancellationTokenSource _cancellationTokenSource; This CancellationTokeSource gets instatiated every time I create a TPL task that uses that particular cancellationtoken The actualy TPL tasks look like this: var dataRetrievalTask = new Task<List<myType>>(() => { // retrieve data and do something foreach (var a in retrievalMethod()) { if (_cancellationTokenSource.Token.IsCancellationRequested)

ios 13 objective-c background task request

依然范特西╮ 提交于 2020-04-11 05:31:32
问题 I've got a question with objective-c and background task request. Restricted to background modes with ios 13. My App does not run in the background more than 30 seconds. Background modes changed with ios 13. I need to register a background task with objective-c like this: BGTaskScheduler.shared.register(forTaskWithIdentifier: "com.SO.apprefresh", using: nil) { task in self.scheduleLocalNotification() self.handleAppRefreshTask(task: task as! BGAppRefreshTask) } and I need schedule when app

Why does my jar file not not contain any class files?

旧街凉风 提交于 2020-04-11 04:35:49
问题 I'm trying to add a task ( gen or gen2 ) to my build.gradle that does exactly the same as the Jar -task: version = "0.0.1" apply plugin: 'java' task('gen', type: Jar) { } task gen2(type: Jar) Running gradle jar generates a JAR-file that contains .class -files, while running gradle gen or gradle gen2 generate a JAR-file that does NOT contain any .class -files. Whats wrong with my class definition? 回答1: To build a jar with all the classes from main, as a default jar task would, do this: task

For Loop result in Overflow with Task.Run or Task.Start

家住魔仙堡 提交于 2020-03-17 10:41:50
问题 got a Problem, hope someone can help me out. i try to start 4 Task in an Loop but im getting an ArgumentOutOfRangeException: for (int i = 0; i < 4; i++) { //start task with current connection tasks[i] = Task<byte[]>.Run(() => GetData(i, plcPool[i])); } The Loop gets an Overflow because i = 4 if i start the Tasks without a Loop, they run without any Problems: tasks[0] = Task<byte[]>.Run(() => GetData(0, plcPool[0])); tasks[1] = Task<byte[]>.Run(() => GetData(1, plcPool[1])); tasks[2] = Task

Running a background thread on a RESTful WebApi request

本小妞迷上赌 提交于 2020-03-04 07:54:28
问题 Background Workflow: I have a client (jquery/ajax html page) calling our RESTful WebAPI to get some data (Patient 'encounters' - e.g. admission to a hospital, visit to a clinic, etc.). e.g. public async Task<string> GetEncounters(string patientId) { PatientChart patientChart = await _myService.GetPatientChart(patientId); string message = string.Empty; if (patientChart.Encounters.Status == PatientChart.StatusNotApplicable) { message = "List of Encounters is not available. A request has been

Activity、Task、应用和进程

假如想象 提交于 2020-03-01 12:05:06
很想弄清楚启动一个Activity和Task(任务)的关系,网上也有很多相关资料,由从源码来具体分析的,也有针对launchmode来分析,但都不是自己的,理解起来总不是那么容易,为此,尝试着自己去理解其中的逻辑。不过事先需要弄清楚两个问题: 谁负责管理Activity? Android的framework框架中采用C/S的方式实现由后台服务ActivityManagerService(很多书上将其简称为Ams)来管理具体的Acitivity实例,虽然Ams命名为ActivityManagerService,但是它其实不仅仅管理Activity,他还管理除Acitvity外的其它三大组件,还包括Intent、pendingintent、apk进程和task等等,具体可以查看源码frameworks\base\services\java\com\android\server\am下面的Ams源码和相关的*Record类。 网上资料显示在2.3以后的SDK中,Ams将原来的HistoryRecord类重新命名为ActivityRecord类,并将其原来Ams中的一些处理抽出来成为一个ActivityStack类,每一个Activity实例对应一个ActivityRecord对象,并存放在ActivityStack中,手机一旦启动,就会启动一个Ams服务