Sunday, 15 April 2012

C# process does not stop executing -



C# process does not stop executing -

i having problem c# 2008 windows application not finishing executing , trying determine how resolve issue. c# 2010 console application written phone call c# 2008 console application in turn calls web service. changed both of these applications windows application since did not want dos pop windows.

the problem called c# 2008 windows application never finishes executing. process stays in memory.

the code listed below part of code c# 2010 application.

private static logger logger = logmanager.getcurrentclasslogger(); seek { process eprocess = new process(); strconsoleapplocation = configurationmanager.appsettings["client_location"]; string process_arguments = null; erpt_process.startinfo.useshellexecute = false; erpt_process.startinfo.filename = strconsoleapplocation; process_arguments = " 1 cli"; eprocess.startinfo.arguments = process_arguments; eprocess.start(); eprocess.waitforexit(1800); process_arguments = null; eprocess.startinfo.useshellexecute = false; process_arguments = " 2 tim"; eprocess.startinfo.arguments = process_arguments; eprocess.start(); eprocess.waitforexit(1800); eprocess.dispose(); process_arguments = null; } grab (exception e) { logger.error(e.message + "\n" + e.stacktrace); }

i know c# 2008 app never finishes looking @ processes in memory. in add-on if alter line of code following: eprocess.waitforexit();, application never returns called program.

in c# 2008 called application, lastly line of code executed following:

environment.exit(1);

thus resolve problem, have next questions:

if have recommendations on how can alter code listed above, allow me know recommendations are?

since these 2 programs in production right now, wondering if have suggestions on how can resolve problem "bandaid" fix? there way can stop c# 2008 process running when c# 2010 programme finishes executing? there way create c# 2008 application kill own process when has finished executing? if so, can show me code on how solve problem?

for long term fix, can tell me how determine why c# 2008 process not stop , how can prepare it? utilize profiler, company has professional version of visual studio 2010. can tell me recommendations are?

waitforexit(), i.e., waits indefinitely process waiting on end, whereas waitforexit(int milliseconds) waits specified duration , times out.

from have written, c# 2008 programme launching c# 2010 programme never terminating. can due few reasons.

it waiting user input.

it stuck in infinite loop.

if multi-threaded, 1 of threads might not have completed execution , keeping process live (in case thread not set background thread).

try running straight command line see doing.

if behaviour of c# 2008 programme correct/as expected when executed command line behaving differently when executed c# 2010 program, verify arguments match under both scenarios.

you can kill running process using pskill. can like:

if (!process.waitforexit(1800)) { // launch process pskill kill c# 2008 programme }

finally, can debug running programme opening c# solution/project , using attach process command, find under debug menu bar item in visual studio.

c# process

No comments:

Post a Comment