0

I'm using one .EXE program written on C# (bought it from one company).
Sometimes I need to close it (from outside, not manually - I use my small C# program that does Process.Kill instead when needed)
If the program is not doing anything - I can kill it easily.
But if it's doing some "work" (I think it's either "timer", or "backgroundworker" in their code) - it closes, but gives a small popup saying "Fatal Error" (and the "Ok" button). I click "Ok" and then it gives a bigger popup saying this:

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at
System.Windows.Forms.UnsafeNetiveMethods.DispatchMessageA(MSG&msg)
at 
System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UNsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(in t32 dbComponentID, Int32 Reason, Int32 pv LoopData)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason ApplicationContext context)
at
System.Windows.Forms.Applicaion.ThreadContext.RunMessageLoop(Int32reason, ApplicationContext context_
at System.Windows.Forms.Application.Run(Form mainForm)
at cawf.xad70bf2c5a1a269d.xef498c90a0302180()

(CAWF is the name of their process that I just killed).
After I click Ok here - I have to kill it again and only then it dies.
Their support says it's Windows error so there's nothing they can do.
My guess is that it's their backgroundworker that doesn't want to die when interrupted in the middle of something.

Is there any possible way to kill it "good way" (so that it does not give these errors)?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
John Smith
  • 891
  • 1
  • 11
  • 17

2 Answers2

2

Yes, post a WM_CLOSE to its main window and let it close gracefully. See this answer for details: How to use WM_Close in C#?

Community
  • 1
  • 1
spender
  • 117,338
  • 33
  • 229
  • 351
0

if you want to kill it then kill it through run command

win key + R

then type

tskill cawf

or

tskill cawf.exe

try one of those.

Senad Meškin
  • 13,597
  • 4
  • 37
  • 55