multithreading

How do I properly cancel Parallel.Foreach?

安稳与你 提交于 2020-12-03 17:12:39
问题 I've got code which looks something like this: Parallel.Foreach(ItemSource(),(item)=>DoSomething(item)); ItemSource() produces an infinite stream of items. I want the loop to exit once some condition has been met, and I'd rather do it without throwing an exception in DoSomething (I consider this approach a bad programming style). Ideally, there would be something like cancellationToken. I would call cancellationToken.Activate() in one or more threads, after which parallel.foreach would stop

Dependency injected services used in a new task

不羁的心 提交于 2020-12-02 07:19:06
问题 I'm using dependency injection to access my services when needed but i'm now wanting to create a concurrent task but this is causing issues due to dependency injected objects and their lifetimes. I've read this article (Heading: Prevents multi-threading): Link And from that, I've gathered that this isn't possible. My objective is to let the client send a request to begin a job that could take longer than the connection timeout of the client, thus I want to have an endpoint that initiates a

Dependency injected services used in a new task

有些话、适合烂在心里 提交于 2020-12-02 07:18:26
问题 I'm using dependency injection to access my services when needed but i'm now wanting to create a concurrent task but this is causing issues due to dependency injected objects and their lifetimes. I've read this article (Heading: Prevents multi-threading): Link And from that, I've gathered that this isn't possible. My objective is to let the client send a request to begin a job that could take longer than the connection timeout of the client, thus I want to have an endpoint that initiates a

Dependency injected services used in a new task

为君一笑 提交于 2020-12-02 07:18:04
问题 I'm using dependency injection to access my services when needed but i'm now wanting to create a concurrent task but this is causing issues due to dependency injected objects and their lifetimes. I've read this article (Heading: Prevents multi-threading): Link And from that, I've gathered that this isn't possible. My objective is to let the client send a request to begin a job that could take longer than the connection timeout of the client, thus I want to have an endpoint that initiates a

Lock free synchronization

断了今生、忘了曾经 提交于 2020-12-01 10:46:11
问题 My question is related to multithreading lock-free synchronization. I wanted to know the following: What are general approaches to achieve this? I read somewhere about LockFreePrimitives like CompareAndExchange (CAS) or DoubleCompareAndExchange (DCA) but no explanation for those were given? Any approaches to MINIMIZE use of locks? How does Java/.NET achieve their concurrent containers? Do they use locks or lock-free synch? Thanks in advance. 回答1: Here are some general approaches that can

Delphi : How to create and use Thread locally?

▼魔方 西西 提交于 2020-12-01 07:43:25
问题 My database is in a VPS and I should get some query from my tables Because of getting query from server taking long time ( depending on Internet speed ! ) , I want to use threads to get queries Now I create a thread and get query and then send result to my forms with sending and handling messages I want to know is it possible to create and use a thread locally ?!? My mean is : procedure Requery; var ... begin Create Thread; ... Pass my Query Component to Thread ... Getting Query in Thread; ..

Delphi : How to create and use Thread locally?

依然范特西╮ 提交于 2020-12-01 07:42:38
问题 My database is in a VPS and I should get some query from my tables Because of getting query from server taking long time ( depending on Internet speed ! ) , I want to use threads to get queries Now I create a thread and get query and then send result to my forms with sending and handling messages I want to know is it possible to create and use a thread locally ?!? My mean is : procedure Requery; var ... begin Create Thread; ... Pass my Query Component to Thread ... Getting Query in Thread; ..

Delphi : How to create and use Thread locally?

点点圈 提交于 2020-12-01 07:42:01
问题 My database is in a VPS and I should get some query from my tables Because of getting query from server taking long time ( depending on Internet speed ! ) , I want to use threads to get queries Now I create a thread and get query and then send result to my forms with sending and handling messages I want to know is it possible to create and use a thread locally ?!? My mean is : procedure Requery; var ... begin Create Thread; ... Pass my Query Component to Thread ... Getting Query in Thread; ..

What is a process_reaper thread in Java?

感情迁移 提交于 2020-12-01 07:16:16
问题 I'm getting hundreds of these process_reaper threads that build up over time in my application. Anyone have any idea what these may be? They seem to be in my use of Runtime.exec() however I'm destroying my process in a finally statement but they still show up screen shot: http://www.dropmocks.com/mBxM5 Process proc = null; String line; try { logger.info("Trying to execute command " + Arrays.asList(command).toString().replace(",", "")); proc = Runtime.getRuntime().exec(command); } catch

What is a process_reaper thread in Java?

倖福魔咒の 提交于 2020-12-01 07:10:19
问题 I'm getting hundreds of these process_reaper threads that build up over time in my application. Anyone have any idea what these may be? They seem to be in my use of Runtime.exec() however I'm destroying my process in a finally statement but they still show up screen shot: http://www.dropmocks.com/mBxM5 Process proc = null; String line; try { logger.info("Trying to execute command " + Arrays.asList(command).toString().replace(",", "")); proc = Runtime.getRuntime().exec(command); } catch