multithreading

c# TaskFactory ContinueWhenAll unexpectedly running before all tasks complete

妖精的绣舞 提交于 2020-05-31 04:54:05
问题 I have a data processing program in C# (.NET 4.6.2; WinForms for the UI). I'm experiencing a strange situation where computer speed seems to be causing Task.Factory.ContinueWhenAll to run earlier than expected or some Tasks are reporting complete before actually running. As you can see below, I have a queue of up to 390 tasks, with no more than 4 in queue at once. When all tasks are complete, the status label is updated to say complete. The ScoreManager involves retrieving information from a

Python Sockets, Advanced Chat Box

我们两清 提交于 2020-05-31 04:20:11
问题 I want to create a server that handles a lot of clients at the same time ( handles : receiving data from clients and sending data to all clients at the same time!!!) Actually i'm trying to create a chat box. The program will work like this: 1) There's going to be a server which handles the clients. 2) More than one clients can join the server. 3) Clients send messages (Strings) to the server. 4) The server receive's the message from a client and then it send's it to all the clients except the

Python Sockets, Advanced Chat Box

非 Y 不嫁゛ 提交于 2020-05-31 04:19:33
问题 I want to create a server that handles a lot of clients at the same time ( handles : receiving data from clients and sending data to all clients at the same time!!!) Actually i'm trying to create a chat box. The program will work like this: 1) There's going to be a server which handles the clients. 2) More than one clients can join the server. 3) Clients send messages (Strings) to the server. 4) The server receive's the message from a client and then it send's it to all the clients except the

How to make ImageIcon on JLabel update faster with less latency

痴心易碎 提交于 2020-05-30 08:13:09
问题 I am trying to update an ImageIcon on a JLabel which sits on a JLayeredPane, but there is a lot of latency between when the setting thread sends the proper state to the JLabel object and when the GUI displays the ImageIcon of the proper state. The following code is an example of the issue, look for the difference in time between the print of the button being on/off and when the displayed icon gets lighter/darker. The setting thread: new Thread(new Runnable() { // setting thread @Override

How to make ImageIcon on JLabel update faster with less latency

偶尔善良 提交于 2020-05-30 08:13:02
问题 I am trying to update an ImageIcon on a JLabel which sits on a JLayeredPane, but there is a lot of latency between when the setting thread sends the proper state to the JLabel object and when the GUI displays the ImageIcon of the proper state. The following code is an example of the issue, look for the difference in time between the print of the button being on/off and when the displayed icon gets lighter/darker. The setting thread: new Thread(new Runnable() { // setting thread @Override

Xamarin.forms giving “invalid cross thread access” Exception in windows8 emulator

一笑奈何 提交于 2020-05-30 07:15:27
问题 Xamarin.forms is working fine in android phones but in window8 emulator it is not loading image and giving invalid cross thread access exception. I'm using Embedded Image Technique, I'm storing all images in common folder and accessing from shared project. snapshot of my project is as follows: Error is As follows : In window8 simulator images are not loading Any help will be much appreciated. 回答1: This is because you are updating a UI element on a non UI thread, you want to use Device

How to use threading for multiply GET requests and compare

与世无争的帅哥 提交于 2020-05-30 05:14:50
问题 I have been trying to figure out how I can speed up and also get some knowledge with threading. I have been trying to create a function where I have put two GET requests. For each link I scrape some data and then I save it to a list which returns and then I will use that to compare to see if there has appeared new links in one of these links: """ def getScrapeLinks(self, siteURL): response = requests.get( siteURL, timeout=5 ) if response.ok: bs4 = soup(response.text, 'lxml') links = ['{}'

How should I use epoll to read and write from the same FD

雨燕双飞 提交于 2020-05-29 10:46:39
问题 Environment Linux x64 Ubuntu 16.4 C++ Use-case Async IO ( epoll ) A socket is used for both reading and writing Read & Write operations and not in sync and are iteratively done on the socket Sample flow Setup socket ( EPOLL_CTL_ADD ) Start read ( EPOLL_CTL_MOD + EPOLLIN | EPOLLONESHOT ) While waiting for data to be read [a] Write some data ( EPOLL_CTL_MOD + EPOLLOUT | EPOLLONESHOT ) Problem description At #2 above a EPOLLIN read operation is registered At #3.a, a EPOLLOUT write completion is

How should I use epoll to read and write from the same FD

梦想的初衷 提交于 2020-05-29 10:46:27
问题 Environment Linux x64 Ubuntu 16.4 C++ Use-case Async IO ( epoll ) A socket is used for both reading and writing Read & Write operations and not in sync and are iteratively done on the socket Sample flow Setup socket ( EPOLL_CTL_ADD ) Start read ( EPOLL_CTL_MOD + EPOLLIN | EPOLLONESHOT ) While waiting for data to be read [a] Write some data ( EPOLL_CTL_MOD + EPOLLOUT | EPOLLONESHOT ) Problem description At #2 above a EPOLLIN read operation is registered At #3.a, a EPOLLOUT write completion is

Multi-Thread Firebase function

99封情书 提交于 2020-05-29 07:07:10
问题 So I am developing a Firebase function that accepts requests from users and updates few nodes under a branch these users are listening to. My issue is if the function receives two client requests at the same time, that triggers two functions to execute and update the data at the same time. I know this is typically solved by a transaction, but my updates are done on various nodes not only one value (i.e counter). In a traditional multi-threading programming, this problems is solved by locking