DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Q2 [Ans.] Killing a created process from outside the function that creates it  (Read 5,727 times)

mediaguycouk

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 247
Another question I'm stuck on.

I have two forms (for this example) called Main and Ffmpeg. Inside main there is a [Start] and a [Cancel] button. There is a Start_Clicked function and a Cancel_Clicked function.

Inside Start_Click I start ffmpeg (Ffmpeg ffmpeg = new Ffmpeg). This ffmpeg class opens up ffmpeg.exe and sends some arguments. (The code is in http://www.donationcoder.com/forum/index.php?topic=15549.0)

Now my question is, how can I send proc.Kill(); to ffmpeg? The Cancel_Clicked function doesn't know what ffmpeg is.

Advanced thanks for your help. Learning languages is damn near impossible without people like yourself that help!

Graham
Learning C# - Graham Robinson
« Last Edit: November 04, 2008, 09:28 AM by mediaguycouk »

Ehtyar

  • That News Guy
  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,237
    • Plugin Coding Medal
    • Gathering Badge
You'll want to declare the instance of the ffmpeg class outside of the functions (in a global context), then make use of it within the functions. To show you how this would work we'd need to see more of your code.

Ehtyar.

mediaguycouk

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 247
That's so simple it's brilliant. Why the hell didn't I think of that! I've even done that in a different part of the program.

Learning C# - Graham Robinson

Original address: https://www.donationcoder.com/forum/index.php?topic=15564.0