multithreading

System.Timers.Timer Elapsed intermittently not firing when using an Task.Run with async from Console App

大憨熊 提交于 2021-01-26 13:23:07
问题 I am using a console application and I have batches of 20 URIs that I need to read from and I have found a massive speed boost by making all tasks and running them in parallel then sorting the results on completion in a different thread (allowing the next batch to be fetched). In the calls I am currently using, each thread blocks when it gets the response stream, I also see there is a async version of the same method GetResponseAsync . I understand there are benefits of freeing up the thread

System.Timers.Timer Elapsed intermittently not firing when using an Task.Run with async from Console App

早过忘川 提交于 2021-01-26 13:23:05
问题 I am using a console application and I have batches of 20 URIs that I need to read from and I have found a massive speed boost by making all tasks and running them in parallel then sorting the results on completion in a different thread (allowing the next batch to be fetched). In the calls I am currently using, each thread blocks when it gets the response stream, I also see there is a async version of the same method GetResponseAsync . I understand there are benefits of freeing up the thread

Thread safety on async/await with memory caching

核能气质少年 提交于 2021-01-26 09:47:10
问题 I was having a look at the section on memory barriers as described in http://www.albahari.com/threading/part4.aspx and attempted to make an async/await version of the example provided under 'Do We Really Need Locks and Barriers?': public class Program { static void Main(string[] args) { TestAsync(); Console.ReadKey(true); } private static async void TestAsync() { bool complete = false; Func<Task> testFunc = async () => { await Task.Delay(1000); bool toggle = false; while (!complete) toggle =

Blocking Queue Take out of Order

狂风中的少年 提交于 2021-01-24 18:43:29
问题 I have a simple blocking queue containing Integers. In a multi thread environment I am taking and adding elements to the the back of the queue. BlockingQueue<Integer> test = new LinkedBlockingQueue<Integer>(); The goal is to have adding in order.. and taking be in the same order as well. On the 5th line of my program output, 3 is somehow at the front of the queue before 2 is, despite it appearing that 2 was added first. All of these were added in a single threaded environment, so I know the

Blocking Queue Take out of Order

最后都变了- 提交于 2021-01-24 18:28:23
问题 I have a simple blocking queue containing Integers. In a multi thread environment I am taking and adding elements to the the back of the queue. BlockingQueue<Integer> test = new LinkedBlockingQueue<Integer>(); The goal is to have adding in order.. and taking be in the same order as well. On the 5th line of my program output, 3 is somehow at the front of the queue before 2 is, despite it appearing that 2 was added first. All of these were added in a single threaded environment, so I know the

Blocking Queue Take out of Order

我的未来我决定 提交于 2021-01-24 18:27:22
问题 I have a simple blocking queue containing Integers. In a multi thread environment I am taking and adding elements to the the back of the queue. BlockingQueue<Integer> test = new LinkedBlockingQueue<Integer>(); The goal is to have adding in order.. and taking be in the same order as well. On the 5th line of my program output, 3 is somehow at the front of the queue before 2 is, despite it appearing that 2 was added first. All of these were added in a single threaded environment, so I know the

Blocking Queue Take out of Order

烂漫一生 提交于 2021-01-24 18:24:52
问题 I have a simple blocking queue containing Integers. In a multi thread environment I am taking and adding elements to the the back of the queue. BlockingQueue<Integer> test = new LinkedBlockingQueue<Integer>(); The goal is to have adding in order.. and taking be in the same order as well. On the 5th line of my program output, 3 is somehow at the front of the queue before 2 is, despite it appearing that 2 was added first. All of these were added in a single threaded environment, so I know the

Multiprocessing multithreading GIL?

时光毁灭记忆、已成空白 提交于 2021-01-24 12:38:52
问题 So, since several days I do a lot of research about multiprocessing and multithreading on python and i'm very confused about many thing. So many times I see someone talking about GIL something that doesn't allow Python code to execute on several cpu cores, but when I code a program who create many threads I can see several cpu cores are active. 1st question: What's is really GIL? does it work? I think about something like when a process create too many thread the OS distributed task on multi

Multiprocessing multithreading GIL?

╄→尐↘猪︶ㄣ 提交于 2021-01-24 12:38:25
问题 So, since several days I do a lot of research about multiprocessing and multithreading on python and i'm very confused about many thing. So many times I see someone talking about GIL something that doesn't allow Python code to execute on several cpu cores, but when I code a program who create many threads I can see several cpu cores are active. 1st question: What's is really GIL? does it work? I think about something like when a process create too many thread the OS distributed task on multi

cancellation token in F# threads

只谈情不闲聊 提交于 2021-01-24 10:46:06
问题 I am struggling with the following: I have a system that has its main flow and has two background threads that can be started and stopped, but they're generally very long running as they stop only during configuration changes. I found that the cancellation token in F# gets checked at async points in the code. The worker threads do not perform any async operations; they are doing background work but nothing is asynchronous. A simplified version looks like that: let workerThread (someParameters