thread-safety

Null reference in async loop, but object has no nulls

被刻印的时光 ゝ 提交于 2020-01-06 08:13:40
问题 First, this is not answered by this SO post, as that describes simple/basic object reference problems. What I'm experiencing is related to multithreaded async processing, which the other post doesn't solve. I have a multithreaded .NET winforms app and I'm doing this: if ( paramList != null ) { lock ( paramList ) { foreach ( DictionaryEntry param in paramList ) { command.Parameters.AddWithValue(param.Key.ToString(), param.Value); } } } paramList is an OrderedDictionary . I sporadically get

Null reference in async loop, but object has no nulls

本秂侑毒 提交于 2020-01-06 08:13:06
问题 First, this is not answered by this SO post, as that describes simple/basic object reference problems. What I'm experiencing is related to multithreaded async processing, which the other post doesn't solve. I have a multithreaded .NET winforms app and I'm doing this: if ( paramList != null ) { lock ( paramList ) { foreach ( DictionaryEntry param in paramList ) { command.Parameters.AddWithValue(param.Key.ToString(), param.Value); } } } paramList is an OrderedDictionary . I sporadically get

How to start concurrent threads that acquire a file lock and wait on each other

你离开我真会死。 提交于 2020-01-06 04:31:12
问题 I'm studying the FileLock class. What I want to do is start three Threads that will run at the same time and access a single file. While the file is locked by one thread, I want the other two threads to wait for their turn when the lock is released. However, when I run my code below, the threads don't even start all at the same time--they are started one after the other, as soon as each of their run() methods is finished. I don't understand. public class Main { public static void main(String[

Can I have thread safe per-request configuration for database connection and table_name in ActiveRecord (or Mongoid)?

喜你入骨 提交于 2020-01-06 03:59:04
问题 Also known as the <<"User has many Databases" question.>> The environment My app is modeled like so: user has_many databases database has_many tables table has_many rows row habtm(+value) columns you get the idea! So instead of modelling a database inside a database, I would like to have: a sqlite3 database that holds the users and many sqlite databases for each user Each user will LCRUD his tables in his databases (similar to phpmyadmin) The problem I would like to have thread safe per

Multi threading loop freezes ui

怎甘沉沦 提交于 2020-01-05 15:40:52
问题 I'm having trouble with mutli threading programming in my application. Actually, the code looks something like this: Private Delegate Sub IniciarDiscagemDelegate() Private Sub CallBack() 'do some stuff.... ThreadDiscagem = New Threading.Thread(AddressOf IniciarDiscagem) ThreadDiscagem.IsBackground = True ThreadDiscagem.Start() End Sub Private Sub IniciarDiscagem() If Me.InvokeRequired() Then Me.BeginInvoke(New IniciarDiscagemDelegate(AddressOf IniciarDiscagem)) Exit Sub End If Do While True

Multi threading loop freezes ui

徘徊边缘 提交于 2020-01-05 15:37:10
问题 I'm having trouble with mutli threading programming in my application. Actually, the code looks something like this: Private Delegate Sub IniciarDiscagemDelegate() Private Sub CallBack() 'do some stuff.... ThreadDiscagem = New Threading.Thread(AddressOf IniciarDiscagem) ThreadDiscagem.IsBackground = True ThreadDiscagem.Start() End Sub Private Sub IniciarDiscagem() If Me.InvokeRequired() Then Me.BeginInvoke(New IniciarDiscagemDelegate(AddressOf IniciarDiscagem)) Exit Sub End If Do While True

Rails 3.2.11 asset precompile fails if threadsafe! enabled

橙三吉。 提交于 2020-01-05 07:00:33
问题 I'm on Rails 3.2.11 and ruby 1.9.3.125 My app is working ok in devel and production if threadsafe! off With threadsafe! enabled I get an error during precompiling, in my asset assetsolutions.js.erb (which is the main js file of the application) I use the Workorder class as in the next line if ($('#workorder_worktype').val()=='<%= Workorder::REPAIR %>') with threadsafe! the class can't be found at precompile time, I've done some reasearch and I think it may be related with rails switching off

Rails 3.2.11 asset precompile fails if threadsafe! enabled

旧时模样 提交于 2020-01-05 07:00:13
问题 I'm on Rails 3.2.11 and ruby 1.9.3.125 My app is working ok in devel and production if threadsafe! off With threadsafe! enabled I get an error during precompiling, in my asset assetsolutions.js.erb (which is the main js file of the application) I use the Workorder class as in the next line if ($('#workorder_worktype').val()=='<%= Workorder::REPAIR %>') with threadsafe! the class can't be found at precompile time, I've done some reasearch and I think it may be related with rails switching off

Generic BeginInvoke Scheme to ensure function calls in same threading context

谁说我不能喝 提交于 2020-01-04 14:03:11
问题 I'm moving some code from a winforms control object to a separate object for better modularity. However, there some calls to an external object issuing callbacks, which I have no control of and which can be fired from different threads as the main UI thread. To avoid this I use the well known BeginInvoke scheme to check, whether a call should be transfered to the main UI thread. When I now move this code to my separated object, I have not necessary a Winforms reference anymore. I could handle

Windows API safe termination of thread

China☆狼群 提交于 2020-01-04 05:23:32
问题 I have Delphi application on windows XP. This application works with 100 threads. At some cases i have to terminate thread with fully drops of thread's stack. I looking for function from WinAPI like terminatethread but it not safelly and: Windows Server 2003 and Windows XP/2000: The target thread's initial stack is not freed, causing a resource leak. 回答1: There's no such function. No such function could possibly exist. Windows cannot possibly know which resources are to be tidied up by that