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 561033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:24:27+00:00 2026-05-13T12:24:27+00:00

Pretty new to C# (and I would describe myself as a beginner in programming,

  • 0

Pretty new to C# (and I would describe myself as a beginner in programming, but I’m ambitious), so this is probably something very simple to solve.

I have a function getting called in a switch like this:

            case "PERL_TEST":
            FileInfo fi = new FileInfo("hello.txt");
            mainproc.process_file(fi);
            MessageBox.Show(perl_o);                
            break;

The mainproc.process is a function that calls Perl like this:

myProcess = new Process();
        ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("perl.exe");
        myProcessStartInfo.Arguments = "perly.pl";
        myProcessStartInfo.UseShellExecute = false;
        myProcessStartInfo.RedirectStandardOutput = true;
        myProcessStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
        myProcessStartInfo.CreateNoWindow = true;
        myProcess.StartInfo = myProcessStartInfo;
        myProcess.OutputDataReceived += new DataReceivedEventHandler(Perl_Output);
        myProcess.Start();
        myProcess.BeginOutputReadLine();

The Perl_Output function contains nothing in it, but receives the args: object o, and DataReceivedEventArgs e.

What method would be best to return e.Data to be shown in the messagebox from the original switch (perl_o)? I’m not sure how to do this. I’m not even sure if I have the most efficient method for calling perl externally. The whole application is based on perl being called externally, and returning the data. The part that calls perl is already running on a second thread. Any and all help would be appreciated as I am a beginner… be gentle 🙂

Edit:
e.Data is not declared. It is passed when the event Perl_Output is called. The switch is for basic network commands, in this case: “PERL_TEST”.

perl_o is not declared. I’m looking for a way to make perl_o = e.Data AFTER mainproc.process_file finishes it’s process.

The best overall way for me would be if I could declare the function containing myProcess as string (instead of void), have the function wait for the process to finish running, then return the output of the process.

  • 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-05-13T12:24:27+00:00Added an answer on May 13, 2026 at 12:24 pm

    Does the message have to be shown in the switch statement? If it does, then you could use wait handles or similar to block the current thread until data are returned from the new process, but this is likely not the best approach.

    It might be more sensible to pass a callback into the function from the switch statement:

    case "PERL_TEST":
        FileInfo fi = new FileInfo("hello.txt");
        mainproc.process_file(fi, MessageBox.Show);
        break;
    

    Then in process_file:

    public void process_file(FileInfo fi, Action<string> dataCallback)
    {
        myProcess = new Process();
        ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("perl.exe");
        myProcessStartInfo.Arguments = "perly.pl";
        myProcessStartInfo.UseShellExecute = false;
        myProcessStartInfo.RedirectStandardOutput = true;
        myProcessStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
        myProcessStartInfo.CreateNoWindow = true;
        myProcess.StartInfo = myProcessStartInfo;
        myProcess.OutputDataReceived += (sender, e) =>
            {
                dataCallback(e.Data);
            };
        myProcess.Start();
        myProcess.BeginOutputReadLine();
    }
    

    Or something similar to this anyway, as I can’t see where you’re using the FileInfo object.

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

Sidebar

Related Questions

I am pretty new to php, but I am learning! I have a simple
I'm pretty new to the idea of recursion and this is actually my first
I'm pretty new to my company (2 weeks) and we're starting a new platform
I'm a pretty new C# and .NET developer. I recently created an MMC snapin
I am pretty new to VB.NET - and I'm struggling to convert the signature
I'm pretty new to JSF and the many many related technologies out there. I'm
I'm pretty new to regular expressions. I have a requirement to replace spaces in
I'm pretty new to the C++ build flow, and I'm thinking of switching to
I'm pretty new to the Spring Framework, I've been playing around with it and
I am pretty new to the Unity Application Block and am a little stuck

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.