task

WaitHandleCannotBeOpenedException on Azure web role start with Task.Wait()

我怕爱的太早我们不能终老 提交于 2020-01-11 05:17:26
问题 The following (web) role entry point, after returning, causes the below exception to be thrown. public class WebRole : RoleEntryPoint { public override bool OnStart() { Task.Run(() => { // Anything can be here, but the lamdbda can be empty too... }).Wait(); return true; } } The exception: A first chance exception of type 'System.Threading.WaitHandleCannotBeOpenedException' occurred in mscorlib.dll Additional information: No handle of the given name exists. As apparent this is thrown from the

Start Async Task within a worker thread

ぐ巨炮叔叔 提交于 2020-01-09 11:00:16
问题 I have two questions: Can we start/execute an Async Task within a worker thread? If yes, the methods onPreExecute() , onProgressUpdate(Progress...) and onPostExecute(Result) are invoked on the UI thread? I wanna know that because I have a TCP connection running on a worker thread and when a packet is received I wanna start a new thread to make the parse of this packet and after that refresh some data structures on the UI thread. Thanks in advance! 回答1: From the Android AsyncTask doc: "The

Start Async Task within a worker thread

送分小仙女□ 提交于 2020-01-09 11:00:11
问题 I have two questions: Can we start/execute an Async Task within a worker thread? If yes, the methods onPreExecute() , onProgressUpdate(Progress...) and onPostExecute(Result) are invoked on the UI thread? I wanna know that because I have a TCP connection running on a worker thread and when a packet is received I wanna start a new thread to make the parse of this packet and after that refresh some data structures on the UI thread. Thanks in advance! 回答1: From the Android AsyncTask doc: "The

Returning from a task without blocking UI thread

旧城冷巷雨未停 提交于 2020-01-09 10:48:15
问题 I have a method that returns a datatable. I need for all the sql stuff to run in a thread and then be able to pass back a datatable without it blocking the UI thread. From my understanding, when you call Task.Result it blocks the UI thread until the task has completed. How would I get around this. I read about using await and async but I haven't quite figured out how to use that with the task yet. public static DataTable LaunchLocationMasterListReport(ObservableCollection<string>

How do Tasks in the Task Parallel Library affect ActivityID?

戏子无情 提交于 2020-01-09 09:11:22
问题 Before using the Task Parallel Library, I have often used CorrelationManager.ActivityId to keep track of tracing/error reporting with multiple threads. ActivityId is stored in Thread Local Storage, so each thread get's its own copy. The idea is that when you fire up a thread (activity), you assign a new ActivityId. The ActivityId will be written to the logs with any other trace information, making it possible to single out the trace information for a single 'Activity'. This is really useful

How do Tasks in the Task Parallel Library affect ActivityID?

这一生的挚爱 提交于 2020-01-09 09:09:28
问题 Before using the Task Parallel Library, I have often used CorrelationManager.ActivityId to keep track of tracing/error reporting with multiple threads. ActivityId is stored in Thread Local Storage, so each thread get's its own copy. The idea is that when you fire up a thread (activity), you assign a new ActivityId. The ActivityId will be written to the logs with any other trace information, making it possible to single out the trace information for a single 'Activity'. This is really useful

Limit the number of Tasks in Task.Factory.Start by second

坚强是说给别人听的谎言 提交于 2020-01-09 08:10:10
问题 I've seen a number of posts about limiting the number of tasks at a time (System.Threading.Tasks - Limit the number of concurrent Tasks is a good one). However, I need to limit the number of tasks by second - only X number of tasks per second? Is there an easy way to accomplish this? I thought about creating a ConcurrentDictionary, the key being the current second, and the second being the count so far. The doing a check if we are at 20 for the current second, then stop. This seems suboptimal

Equal loading for parallel task distribution

守給你的承諾、 提交于 2020-01-07 08:19:08
问题 I have a large number of independent tasks I would like to run, and I would like to distribute them on a parallel system such that each processor does the same amount of work, and maximizes my efficiency. I would like to know if there is a general approach to finding a solution to this problem, or possibly just a good solution to my exact problem. I have T=150 tasks I would like to run, and the time each task will take is t=T. That is, task1 takes 1 one unit of time, task2 takes 2 units of

Service stopped when the app removes from recent apps list in android

…衆ロ難τιáo~ 提交于 2020-01-07 03:05:41
问题 In my application I am using service to run background services continuously even the app removes from recent apps list. But the service stopped if I remove the app from recent apps list. Can any one gives me the solution? Thanks, Sekhar 回答1: you have to make and show a notification until your service is running, use below code : startForeground(id, notify.build()); for more information check example project in here . or maybe your problem is like that . good luck. 回答2: Start service by

GCM push & application process

旧城冷巷雨未停 提交于 2020-01-06 13:15:10
问题 I wondered what happens when GCM push has arrived and there is no process alive bound to the application. As you know, a process can be killed from the task manager and also by the system to free-up space. Actually, I tested the case of killing it manually from the task manager and saw no incoming pushes. What about if the system kills the process then ? Thx in advance. 回答1: Referring following table we can say that, App will not get Push notification if Forced closed by user manually.