c# - Service call works in main thread, but crashes when multithreaded -
my company has application keeps track of information related web sites hosted on various machines. central server runs windows service gets list of sites check, , queries service running on target sites response can used update local data.
my task has been apply multithreading process reduce time takes run through sites (almost 3000 sites take 8 hours run sequentially). service runs through successfuly when it's not multithreaded, moment spread out work multiple threads (testing 3 right now, plus watcher thread) there's bizarre crash seems originate call remote services supposed provide data. it's soap/xml call.
when run on test server, service gives , doesn't complete it's task, doesn't stop running. when run through debugger (dev studio 2010) whole thing stops. i'll run it, , seconds later it'll stop debugging, not because completed. not throw exception or give me kind of message. breakpoints can walk through point stops. event logging leads me same spot. stops on line of code tries response web service on other sites. , again: when multithreaded.
i found information suggested there's limit number of connections defaults 2. proposed solution add tags app.config, hasn't solved problem...
<system.net> <connectionmanagement> <add address="*" maxconnection="20"/> </connectionmanagement> </system.net>
i still think might related number of allowed connections, have been unable find information around online well. there straightforward i'm missing? appreciated.
- no crash bizarre escape stack-dump. try going through dump , see if points out obvious function.
- are using third party tool or other component actual service call ? if yes, please check documentation/contact-the-person-who-wrote-it, confirm components thread safe. if not, have large task ahead. :) (i have worked on db not safe, trust me not uncommon find few global static variables thrown around..)
lastly if 100% sure due multiple threads then, put lock in worked thread. covers entire main-while-loop. therotically should not crash not though multi-threaded, have serialized execution. next step reduce scope of thread. say, there 3 functions in main-while-loop , f1(), f2(), f3(), start locking f2() , f3() while leaving f1 unlocked... if things work out, problem somewhere in f2 or f3(). hope got idea of suggest
i know blind man guessing elephant, best can do, if code uses lot many external component not adequately documented.
Comments
Post a Comment