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

  • Home
  • SEARCH
  • 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 8398231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:59:45+00:00 2026-06-09T20:59:45+00:00

Essentially, I have a Do..While loop going through some lines from a text file.

  • 0

Essentially, I have a Do..While loop going through some lines from a text file. I want to process a line, return a value (worked or didn’t), then move to the next line.

I have a function called ProcessTXT that accepts 2 strings. Source and Destination of new file.

Is there a way to set a ReturnedValue string = to the result and have the backgroundworker check to see if the variable changed? And if so, add this value to the list box?

private void TranslatePOD(string strSource, string strDest,)
{
  TextWriter tw = new StreamWriter(strDest);
  TextReader tr = new StreamReader(strSource);
  do
    {
      //My Code doing stuff
      //Need to send a result somehow now, but i have more work to do in this loop
      //Then using tw.writeline() to write my results to my new file
    } while (tr.ReadLine() != null);
}

EDIT: Current test code using Yield. My output is “TestingGround.Form1+d__0”. Did i do something wrong?

namespace TestingGround
{
public partial class Form1 : Form
{
    static IEnumerable<string> TestYield(string strSource) 
    {
        TextReader tr = new StreamReader(strSource);
        string strCurLine = System.String.Empty;

        while ((strCurLine = tr.ReadLine()) != null)
        {
            yield return strCurLine;
        }
    }

    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        string MySource = System.String.Empty;
        MySource = @"C:\PODTest\Export Script\Export\Shipment List.csv";
        listBox1.Items.Add(TestYield(MySource));

    }
}
  • 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-09T20:59:47+00:00Added an answer on June 9, 2026 at 8:59 pm

    Yield is typically used to return results iteratively, or streaming. There are plenty of examples online. There’s one on SO for reading in a file.

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

Sidebar

Related Questions

I have a 1.3GB text file that I need to extract some information from
I have a Java program performing some large analysis tasks, running through a loop
I have to parse a tab-delimited text file with Ruby to extract some data
I have data that I want to pull from a mySQL database and I
I have a basic question about MPI programming in C. Essentially what I want
I have written a console application, which is essentially a Console.ReadLine()-Loop. When the application
I would like some advise on how to optimise the following while loop: double
I have some features content that I want to place after my shop content,
Essentially I have a method of a class called killProgram, which is intended to
Essentially I have an NSMutableArray which contains several NSDictionaries . I wish to sort

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.