task

How to cancel CSharpScript.RunAsync

坚强是说给别人听的谎言 提交于 2019-12-12 12:32:47
问题 How can I stop RunAsync? CancellatioTokenSource cts = new CancellationTokenSource(); //I thought that it's must work, but it don't var script = CSharpScript.Create(code: someCode); await script.RunAsync(cancelletionToken: cts.Token); void button_click() { cts.Cancel() } How else can I do this. And for why such methods need cancellationToken parameter? 回答1: You must do it before the await call, which blocks execution until yout get results, e.g.: var task = script.RunAsync(cancelletionToken:

Unexpected Thread Abort Exception using Tasks. Why?

隐身守侯 提交于 2019-12-12 10:37:20
问题 I have a console application running in an app domain. The app domain is started by a custom windows service. The application uses parent tasks to start several child tasks that do work. There can be many parent tasks with children running at any given time as the timer looks for new work. The handle to all parent tasks is in a List of tasks: static List<Task> _Tasks = new List<Task>(); The windows service is able to send a stop signal to the running application by putting a string token in

Execute Ant task with Maven

旧巷老猫 提交于 2019-12-12 08:53:40
问题 I'm trying to execute with Maven some test written using Ant tasks. I generated the files required to import the task into Maven, but I can't execute them. My POM is defined this way: <build> <plugins> <plugin> <artifactId>maven-ant-plugin</artifactId> <version>2.1</version> <executions> <execution> <phase>generate-sources</phase> <configuration> <tasks> <echo message="Hello, maven"/> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> <

SSIS Write to object variable through script task

耗尽温柔 提交于 2019-12-12 08:06:28
问题 I have some code where i wanna end up with 2 lists. Startings and endings. They contain start date of month and enddate of month. These 2 lists i wanna put in an object variable so i can use the object in a foreachloop container in ssis,and loop through each row with startofmonth and endofmonthdates (variables: min and max) - But i dont know how to Here are my codes: String s = "2013-01-01"; String b = "2014-01-01"; using (SqlConnection connection = new SqlConnection("Server=localhost;Initial

Can I detect when my service is killed by “Advanced Task Killer”

吃可爱长大的小学妹 提交于 2019-12-12 08:02:18
问题 My app runs a geolocalisation service that the user can active or disactive by a toggleButton. To check the status of the service, I write a boolean in the Shared Preferences. I listen the beginning of the service and the end of it thanks to the onDestroy() of my service. My problem is that: When the user kill the service with the "advanced task killer", I can't know that the service is killed, the onDestroy is not called ! How can I deal with that? Thanks for your help. Florent 回答1: When a

How to run a Windows 2008 task from the scheduler with “interact with desktop”

匆匆过客 提交于 2019-12-12 07:33:48
问题 I have a small .NET app that I'm running under Windows 2008 Server via the Task Scheduler. This application needs to open an excel file and then save it as csv. The task fails when I try to open the workbook. If I run it manually without the task scheduler running it, the app works fine. I have it set to "Run with highest privileges" and have "Run weather user is logged on or not" checked. My guess is that this process needs to interact with the desktop similar to check the "interact with

How to activate task in c#?

匆匆过客 提交于 2019-12-12 06:35:45
问题 I'am trying to consume a wcf in windows 8: My code to consume the method generated by the WCF service: public System.Threading.Tasks.Task<Maquette_MyAirport_Win8.FlightService.CitiesResponse> GetAllCitiesAsync(Maquette_MyAirport_Win8.FlightService.BaseRequest request) { return base.Channel.GetAllCitiesAsync(request); } is public testproxy() { _client = new FlightInfoServiceClient(Maquette_MyAirport_Win8.FlightService.FlightInfoServiceClient.EndpointConfiguration.wsHttpBindingConfiguration);

Values “resetting” back to zero after Task is completed C#

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 05:49:39
问题 This is my function, it returns a struct with the number of successful commands, the number of the ones with errors and also the total of both and also the file path from wich they are being exectued in a Iprogress interface. public void ExecuteCommands(string Directories, CdpsiUpdateSql Updater, CdpsiUpdateSqlparser parser, string Log, IProgress<Result> progress) { Result FinalResult = new Result(); int totalWithErrors = 0; int totalSuccess = 0; string[] numArray1 = new string[3]; List

Task.Run without async or await

对着背影说爱祢 提交于 2019-12-12 05:00:01
问题 If I put a few of the methods I'm calling, from my controller, into Task.Run what exactly is this doing? I'm not using an async function and I'm not using await. ... FunctionOne(); FunctionTwo(); return View(FunctionThree().Result); } private void FunctionOne() { Task.Run(() => { .... } } private void FunctionTwo() { Task.Run(() => { .... } } private Task<MyType> FunctionThree() { return Task.Run(() => { .... } } 回答1: As @LasseVKarlsen explains, this code attempts to execute functions One,

Cancelling long running tasks Asp.net

夙愿已清 提交于 2019-12-12 04:36:18
问题 I'm using ASP.NET WebForms. In PostBack I create a Task(task is very long running). In the html page I need a button that can cancel this task. 1. I click button GetResults that Run a task on the server 2. After some waiting I click button Cancel and I need the task will be cancelled How can I do this? 回答1: Though, you can do it, it is generally not a good idea to create a long running task within ASP.NET, especially if they are background tasks. Phil Haack has a great article on this - http: