threadpool

What is the += / -= mean in a delegate data structure in c#?

倖福魔咒の 提交于 2019-12-11 16:46:28
问题 If I have this code: genetic = new Genetic(); genetic.foundNewBestGroupTour += new Genetico.NewBestGroupTourEventHandler(genetico_foundNewBestGroupTour); What does the += do? genetic.foundNewBestGroupTour -= new Genetico.NewBestGroupTourEventHandler(genetico_foundNewBestGroupTour); What does the -= do? 回答1: Read up on events. The += operator in this context calls the event add accessor, while -= calls the remove accessor. This is usually called subscribing and unsubscribing to the event. The

Is it possible to thread pool IMAP connections?

夙愿已清 提交于 2019-12-11 14:11:22
问题 From what I understand IMAP requires a connection per each user. I'm writing an IMAP client (currently just gmail) that supports many (100s, 1000s maybe 10000s+) users at a time. Obviously cutting down the number of open connections would be great. I'm wondering if it's possible to use thread pooling on my side to connect to gmail via IMAP or if that simply isn't supported by the IMAP protocol. 回答1: IMAP typically uses SSL over TCP/IP. And a TCP/IP connection will need to be maintained per

Synchronizing tasks

ぐ巨炮叔叔 提交于 2019-12-11 13:44:22
问题 I am develeping an application that uses a threadpool, submits tasks to it and synchronizes them. The main thread has to wait until all the submitted tasks from a single loop iteration finish and then it submits another bunch of tasks (because the tasks from the next iteration operate on the same data and they will be dependent on one another). My question is, what is the best way to do that? So far, what I have come up with is that each thread, after finishing a task, increments an atomic

Alternative to Thread.Sleep that block

萝らか妹 提交于 2019-12-11 12:54:32
问题 I am looking for an alternative to calling Thread.Sleep which does not block the thread but instead returns the thread back into the thread pool. Does such a thing exist? 回答1: Use Task.Delay await Task.Delay(delay); 回答2: If the thread is returning to the pool, then it isn't going to do any more work in the method in question. Make the next bit of the method a separate method, and create a Timer that calls it. 回答3: You can use also a Timer for example: using System.Timers; private void Main()

Java stack space versus maximum server request threads

这一生的挚爱 提交于 2019-12-11 12:41:50
问题 Are Java stack space and maximum number of request threads in a server related to each other? Can the relationship between them result in the server not responding to requests and hanging? 回答1: Threads are each given their own stack when allocated, and there is a maximum size that each stack can reach (depending on the VM implementation). So, your stack size may be set at 1MB, for example, but you might have 1000 threads giving you a total of 1GB maximum stack use between them. If a stack

ThreadPool.QueueUserWorkItem versus BeginExecuteNonQuery

天涯浪子 提交于 2019-12-11 12:15:01
问题 I have a problem at work with a simple insert method occasionally timing out due to a scheduled clean-up task on a database table. This task runs every ten minutes and during its execution my code often records an error in the event log due to 'the wait operation timed out'. One of the solutions I'm considering is to make the code calling the stored procedure asynchronous, and in order to do this I first started looking at the BeginExecuteNonQuery method. I've tried using the

Are ThreadPool settings global or only for work items?

二次信任 提交于 2019-12-11 11:58:42
问题 If I set ThreadPool.SetMaxThreads in a WinForms application does this setting applies to only work items or for the whole assembly threads like timers and gui updates? I'm building an application which will continuously process semi-short operations, usually around 1 minute each. I first came up with a manual thread creating version which works fine. Since I'm creating a new thread for each operation I'm looking if I can create a faster and more efficient version and I experimented with

How to find the number of runnables waiting to be executed

試著忘記壹切 提交于 2019-12-11 11:29:33
问题 Is there any way to know at a given point in time how many runnables are waiting to be executed by the ExecutorService . For example, assuming that the loop is invoking the execute method faster than the runnable can complete and a surplus accumulates, is there anyway to get a running count of the accumulated runnables? ExecutorService es = Executors.newFixedThreadPool(50); while (test) { es.execute(new MyRunnable()); } 回答1: Is there any way to know at a given point in time how many runnables

How to delay execution within ThreadPool?

雨燕双飞 提交于 2019-12-11 10:45:13
问题 I've written a script in python using multiprocessing.pool.ThreadPool to handle multiple requests concurrently and do the scraping process robust. The parser is doing it's job perfectly. As I have noticed in several scripts that there should be a delay within the scraping process when it is created using multiprocessing , I would like to put a delay within my below script as well. However, This is where I'm stuck and can't find out the right position to put that delay. This is my script so

multiple threads of QWebView in PyQt4

感情迁移 提交于 2019-12-11 10:28:51
问题 Here is the situation: I have a class that loads specific url, also have a list of parameters, that I need to send to this url. I want to use threads to load this url kinda 'simultaneously', in other words in stead of loading one QWebView , than finish it than load another one I want to open 5 windows at a time. OK, So now the problem is, every single window will have different speed, so I need to keep track of what parametrs are in use. for example: params = [1,2,3,4,5,6,7] a = MyClass(1) b