Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8673215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:24:05+00:00 2026-06-12T19:24:05+00:00

in my application i m open Wireshark process and start capturing packts, in the

  • 0

in my application i m open Wireshark process and start capturing packts, in the UI i have Start button who start the capturing and Stop button who stop capturing and i am doing this by killing my wireshark process.
my question is if i am close my application in the middle of the capturing but nor with my Stop button my Wireshark process continue to run, how can i handle this situation and make sure that my process will close if my application crash or someone close it in the middle of capturing

public void startCapturing()
{            
    ThreadStart tStarter = delegate { openAdapterForStatistics(_device); };
    Thread thread = new Thread(tStarter);
    thread.IsBackground = true;
    thread.Start();
    ProcessStartInfo tsharkStartInfo = new ProcessStartInfo();
    tsharkStartInfo.FileName = _tshark; 
    tsharkStartInfo.RedirectStandardOutput = true; 
    tsharkStartInfo.RedirectStandardError = true; 
    tsharkStartInfo.RedirectStandardInput = true; 
    tsharkStartInfo.UseShellExecute = false; 
    tsharkStartInfo.CreateNoWindow = true; 
    tsharkStartInfo.Arguments = string.Format(" -i " + _interfaceNumber + " -s " + _packetLimitSize + " -w " + _pcapPath);
    _tsharkProcess.StartInfo = tsharkStartInfo;
    _tsharkProcess.ErrorDataReceived += _cmdProcess_ErrorDataReceived;
    _tsharkProcess.OutputDataReceived += tshark_OutputDataReceived; 
    _tsharkProcess.EnableRaisingEvents = true; 
    _tsharkProcess.Start();
    _tsharkProcess.BeginOutputReadLine(); 
    _tsharkProcess.BeginErrorReadLine();                  
    FileInfo fileInfo = new FileInfo(_pcapPath);
    string directoryName = fileInfo.DirectoryName;
    DirectoryInfo directoryInfo = new DirectoryInfo(directoryName);
    FileInfo[] dirs = directoryInfo.GetFiles();
    _file = dirs.FirstOrDefault(f => f.Name.Equals(fileInfo.Name));
    _tsharkProcess.WaitForExit(); 
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:24:07+00:00Added an answer on June 12, 2026 at 7:24 pm

    Assuming you’re handling exceptions using try-catch, you can make sure the Wireshark process is closed in the finally block at the end of your topmost try-catch statement. From the MSDN documentation:

    “The finally block is useful for cleaning up any resources allocated in the try block. Control is always passed to the finally block regardless of how the try block exits.”

    For example:

    try
    {
        // Your application's code.
    }
    catch( Exception )
    {
        // Handle, log, whatever.
    }
    finally
    {
        // Make sure Wireshark process is killed.
    }
    

    The code in the finally block will always get executed whether or not there was an exception.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Chaingin my question. I have my C# application open a nodes data base. So
When no users have the any pages in an application open, it will unload
I have a 64 bit Enterprice SuSE 11 I have an application which open
I have built an open-source application from the source code. Unfortunately, the original executable
Lets say UserA and UserB both have an application open and are working with
I'm building a phonegap application for my blackberry. When I have the application open
It is sometimes desirable to have your application open the default application for a
I have an application that open an external application to read PDF files. here
I have an application that open's some dynamic popup either using window.open() or using
I am open WireShark using command line and start capture the packets, when i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.