c# - Thread Context Switching Issue -


i have function that, argument sake, has 2 lines of code.

line line b 

both lines calls third party web service work. appears though service call on line b contingent on being called (time-wise) after call line a. works fine in non-threaded environment application threading lots (potentially 100) of these calls.

the problem threading, believe, context switching between threads causing enough time (a small amount of time) elapse between call on line , call on line b it's causing call on line b throw custom soap exception.

my knowledge of threading doesn't extend situation this. there anyway make sure call on line b happens after call on line without thread context switching occurring in between?

if need these lines called can lock them, meaning nothing else enter section until complete:

lock(lck) {     line     line b } 

however, may cause problems if 100 threads doing - lose parallelism. in fact, whatever do, if general requirement, lose degree of parallelism.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -