task

Keep running one task every time Signalr Hub class is called

倾然丶 夕夏残阳落幕 提交于 2019-12-11 05:33:46
问题 I want to monitor CPU performance on my ASP.NET MVC5 application and users are able to select the PC they want to be monitored. I use SignalR for monitoring real time CPU performance. It works well for first CPU, the problem is once user select another PC to be monitored, another new Task according to this link will be created so that both of the previous and new Task will sent their data to the client chart. What is the solution for handling my problem so that once user change the PC just

Parallel.ForEach not setting all values in loop

﹥>﹥吖頭↗ 提交于 2019-12-11 05:19:21
问题 I am querying a sql data base for some employees. When i receive these employees I and looping each one using the Parallel.ForEach. The only reason I'm looping he employees that was retrieved from the database is so expand a few of the properties that I do not want to clutter up the data base with. Never-the-less in this example I am attempting to set the Avatar for the current employee in the loop, but only one out of three always gets set, none of the other employees Avatar ever gets set to

Using a CancellationToken to cancel a task without explicitly checking within the task?

六眼飞鱼酱① 提交于 2019-12-11 05:07:36
问题 Background: I have a web application which kicks off long running (and stateless) tasks: var task = Task.Run(() => await DoWork(foo)) task.Wait(); Because they are long running, I need to be able to cancel them from a separate web request. For this, I would like to use a CancellationToken and just throw an exception as soon as the token is canceled. However, from what I've read, Task Cancellation is cooperative, meaning the code the task is running must explicitly check the token to see if a

Creating spark tasks from within tasks (map functions) on the same application

折月煮酒 提交于 2019-12-11 05:03:49
问题 Is it possible to do a map from a mapper function (i.e from tasks) in pyspark? In other words, is it possible to open "sub tasks" from a task? If so - how do i pass the sparkContext to the tasks - just as a variable? I would like to have a job that is composed from many tasks - each of these tasks should create many tasks as well, without going back to the driver. My use case is like this: I am doing a code porting of an application that was written using work queues - to pyspark. In my old

System.Threading.Tasks

我只是一个虾纸丫 提交于 2019-12-11 04:48:08
问题 i am trying to use that reference. i know it is in c# 4. i don't know what i currently have. but basically, when i write the line: Task.Factory.StartNew(someMethod); it tells me that it is a mistake. is there any way to solve it so my ide will identify that library (Task Parallel Library)? 回答1: You just need a using directive of using System.Threading.Tasks; You shouldn't need to add any extra references - Task is in mscorlib. Are you sure you're targeting .NET 4? Check in your project

is it possible to run a task scheduler in bottle web framework

纵饮孤独 提交于 2019-12-11 04:06:40
问题 Does anyone have any examples on how to integrate a task scheduler in Bottle. Something like APScheduler or sched? 回答1: I would suggest threading it allows the webserver to be unaffected by the scheduled tasks that will either be in a queue or written into the code itself. 来源: https://stackoverflow.com/questions/10477310/is-it-possible-to-run-a-task-scheduler-in-bottle-web-framework

How can I create new Task<T>( async( ) => { return new T( ); } );? [duplicate]

北城余情 提交于 2019-12-11 04:03:19
问题 This question already has answers here : Cannot convert lambda expression to type “…” because it is not a delegate type (2 answers) Closed 4 years ago . I need to create a function which will return a task that will be executed at another time. I would like for that task to return a value (preferably through await ing it). I would also like to be able to await methods/functions within that task. When I try to create a simple conceptual function which should do what I want, I get a red-line

How to create nested element for ant task?

时光怂恿深爱的人放手 提交于 2019-12-11 03:59:53
问题 Is it possible to create the nested element for any ant task. For e.g. <copy todir="../backup/dir"> <fileset dir="src_dir"/> <filterset> <filter token="TITLE" value="Foo Bar"/> </filterset> </copy> Here for the task copy we are having nested element as filterset . Now, i would like to create my own nested element encryptfilterset for the task copy . <copy todir="../backup/dir"> <fileset dir="src_dir"/> <encryptfilterset> <filter token="TITLE" value="Foo Bar"/> </encryptfilterset> </copy> How

Rethrowing exception in Task doesn't make the Task to go to faulted state

牧云@^-^@ 提交于 2019-12-11 03:59:18
问题 Consider following scenario var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(2)); var startNew = Task.Factory.StartNew(() => { var currentThread = Thread.CurrentThread; try { using (cancellationTokenSource.Token.Register(currentThread.Abort)) new AutoResetEvent(false).WaitOne(Timeout.InfiniteTimeSpan); } catch (ThreadAbortException abortException) { throw new TimeoutException("Operation timeouted", abortException); } }, cancellationTokenSource.Token,

task based async pattern for wcf

时光怂恿深爱的人放手 提交于 2019-12-11 03:59:06
问题 I am implementing task based async pattern for wcf. The method includes stored procedure execution and lots of processing on the data it got. As well it throws an exception the question is how to implement that option 1. *await command.ExecuteScalarAsync(); //run 10000 lines of processing including exception handling* option 2 *await command.ExecuteScalarAsync(); Task.Factory.StartNew(() => run 10000 lines of processing including exception handling);* may be there other options...? pros and