c# - Detect 100% CPU load by a referenced library -


i have asp.net (c#) website uses third party dll process data users post via web form. call pretty straightforward:

string result = thirdpartylib.processdata(mystring); 

once in blue moon library hangs , (according hosting provider logs) consumes 100% of cpu. website hosted on shared hosting, have no access iis or event logs. when happens, website automatically stopped hosting provider performance monitor, , have manually switch on.

now, know right thing to investigate problem , fix (or replace) dll. it's third-party software, unuable fix it, , support not helpful @ all. moreover, can't reproduce problem. replacing library pain too.

is there way in c# detect when dll starts consuming 100%cpu , kill process automatically asp.net code?

you cannot "detect" if current process hanging because caller of method (third party or not) you're not in control until returns.

what can move call third party library separate executable , have output result via standard output (you can use console.writeline(string) this).

once you've done that, can start separate process runs executable, read result via standardoutput , use waitforexit(int) wait amount of time (maybe few seconds) process finish. return value of waitforexit() tells if process exited. in case didn't, can kill() , move on without iis worker process hanging whole.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -