task

C# - Error propagation with ContinueWith

空扰寡人 提交于 2019-12-08 12:57:47
问题 I'm a threading newbie and am trying to use SemaphoreSlim to allow me to run a set number of long tasks simultaneously. My challenge is that, given the way I've written it, any exceptions are not being captured correctly. Here's a very simplified example of my current code: public void ThreadTest() { try { var currentTasks = new List<Task>(); SemaphoreSlim maxThread = new SemaphoreSlim(2); for (int i = 1; i < 5; ++i) { maxThread.Wait(); var testTask = Faulty().ContinueWith(tsk => maxThread

Task queue for wp8?

拜拜、爱过 提交于 2019-12-08 12:41:31
问题 What is a correct way to queue complex tasks in wp8? The tasks consists of the following: Showing a ProgressIndicator through updating a model variable Fetching or storing data to a wcf service ( UploadStringAsync ) Updating potentially data bound model with the result from UploadStringCompleted . Hiding the ProgressIndicator through updating a model variable Currently I've been working with a class owning a queue of command objects, running a single thread that is started when an item is

How to make Callable wait till execution?

纵饮孤独 提交于 2019-12-08 12:13:34
问题 I have One Callable which I invoked using FutureTask<Integer> task = new FutureTask<Integer>(new MyCallable(name, type)); pool = Executors.newSingleThreadExecutor(); pool.submit(task); I want to know Is execution is continue after pool.submit(task) or It will wait for callable to complete its execution? In short I just want to know is there any method like thread.join() for Callable? 回答1: ... is there any method like thread.join() for Callable? The pool.submit(callable) method returns a

How to extract data from returned Tasks in an async method in c# in Windows 10 [duplicate]

我怕爱的太早我们不能终老 提交于 2019-12-08 11:58:25
问题 This question already has answers here : Method return a task, how get the return-value? (2 answers) Closed 4 years ago . How to extract the data from the returned value of getResponseFromUrl in below foreach loop: Here i am unable to extract the data from returned value. I am building an app in windows 10 universal app development. var response = NetworkingCalls.getResponseFromUrl(url, requestDictionary); foreach (KeyValuePair<string, object> item in response) { Util.debugLog(item.Key

How do task killers work?

坚强是说给别人听的谎言 提交于 2019-12-08 11:50:33
问题 The usefullness of task killer apps is debated, but I'm wondering: how do they actually work? How is it possible to kill particular process? Is there an API for this, and if so what does it actually do ? EDIT Worth adding: I saw task killer apps kill processes on not rooted devices . So, I wonder how is it possible to kill process, which you don't own in Android? 回答1: In a nutshell, Automatic Task Killers work by polling the OS for a list of currently running processes and the memory they are

How do you find the Main Window thread in UWP?

六眼飞鱼酱① 提交于 2019-12-08 10:10:10
问题 I have a library that needs to call the main windows thread in UWP when it receives a message from a communication channel (let say, a message indicating a check box should be checked). The library saves a copy of the SynchronizationContext when it starts up, so it can Post back to it when the data comes in, but the trouble is, I'm not guaranteed that the caller of this library is on the main thread when it's initialized. Is there some simple, guaranteed way to obtain the Main Window Thread

Return the ReferenceCopyLocalPaths from <MSBuild> task

喜你入骨 提交于 2019-12-08 08:56:15
问题 I have custom MSBuild project file with few <ProjectReferences> . I'm calling the <MSBuild Projects="@(ProjectReference)" Targets="Build"> task and I can get all the built assemblies using the <Output TaskParameter="TargetOutputs" ItemName="OutputAssemblies" /> element and I'm copying @(OutputAssemblies) to destination directory. I want to able to get the @(ReferenceCopyLocalPaths) item property from the ResolveAssemblyReferences target but I can't figure out how to output this property.

List MS Windows tasks

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-08 08:39:26
问题 Is there a "built-in" way to list all MS Windows tasks currently running? I've googled a bit and found a workaround via shell("tasklist") , but I don't really like the structure of the resulting R object as its pretty "captured-output-only" like (i.e. the resulting object is a character vector containing things like line numbers etc.) and I would have to fire some regular expressions at it to turn it into something like a data frame or the like: value <- shell("tasklist", intern=TRUE) > value

Serial Task Executor; is this thread safe?

寵の児 提交于 2019-12-08 08:26:49
问题 I have a class that I've created to allow asynchronous sequential execution of tasks, using the ThreadPool as the means of execution. The idea is that I'll have multiple instances running serial tasks in the background, but I don't want to have a separate dedicated Thread for each instance. What I'd like to check is whether this class is actually thread safe. It's fairly brief, so I thought I'd run it by the experts here, in case I'm missing something obvious. I've omitted a few of the

RabbitMq Handle Received message in async way

非 Y 不嫁゛ 提交于 2019-12-08 08:19:20
问题 I'm using RabbitMq to process messages I receive on a bus. I was wondering if there's a better way to process the message I receive (maybe using async/await pattern) Here's a snippet of my code connection = connectionFactory.CreateConnection(); channel = connection.CreateModel(); channel.QueueDeclare(queue: Constants.RabbitListeningQueue,durable: false,exclusive: false,autoDelete: false,arguments: null); channel.QueueDeclare(queue: Constants.RabbitMqRequestInsertedQueue,durable: false