multithreading - Error while retrieving values from C# Thread callback -


i have following piece of code generate 2 threads below in method2

thread[] arrthreads = new thread[2];  thread t1 = new thread(() => {     value1 = this.method1(<some params>); }); t1.start(); arrthreads[0] = t1;  thread t2 = new thread(() => {     value2 = this.someothermethod(<some params>); }); t2.start(); arrthreads[1] = t2;  // code waits both threads on or threshold, whichever comes first! 

this works fine on dev. on release iis production machine, following error encountered.

    @ system.data.rbtree`1.getnodebyindex(int32 userindex)      @ system.data.rbtree`1.get_item(int32 index)      @ system.data.datarowcollection.get_item(int32 index)      @ namespace.class.method1(params) in d:\xxxx\class.cs:line 11309      @ namespace.class.<>c__displayclasse.<method2>b__a() in d:\xxxx\class.cs:line 11687      @ system.threading.executioncontext.runtrycode(object userdata)      @ system.runtime.compilerservices.runtimehelpers.executecodewithguaranteedcleanup(trycode code, cleanupcode backoutcode, object userdata)      @ system.threading.executioncontext.run(executioncontext executioncontext, contextcallback callback, object state) @ system.threading.threadhelper.threadstart() 

can me out error please? in advance.

you need check happening in namespace.class.method1, in d:\xxxx\class.cs:line, on-or-about (sometimes line number tracking gets little screwy) 11309. expect doing like:

var row = somedatatable.rows[0]; 

at point, there are no rows - perhaps query returned no data reason (check query). theoretically possible related unsynchronized threading concerns (since start 2 threads), or race condition - again: don't have enough context that. until then, there no reason presuppose relates multi-threading, keep in mind possibility if have multiple threads mutating same state data.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

IIS->Tomcat Redirect: multiple worker with default -