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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:57:19+00:00 2026-05-24T23:57:19+00:00

So I have a basic application written in C#. It basically writes a file

  • 0

So I have a basic application written in C#. It basically writes a file of inventory. It will just stop half way through creating the file. The I am really confused on what is going on here because if I run it in the IDE it will just stop working. The file is stopped at different stops in the file so it is not a singular event. I am using a threadpool if that makes a different. I have a loop that goes through a file and reads the file and cues a new thread. It is just really hard to debug something if there is no error.

  static void Main(string[] args)
    {
        //string asins;
        Readfile r = new Readfile();
        r.read();

        Console.WriteLine("Press any key to exit.");
        System.Console.ReadKey();

        //Thread.Sleep(60000);

        //createoutward c = new createoutward();
       // c.read();

        //p.print(s.scrap(r.read()));

    }

My method making the thread

public string[] read()
    {
        ThreadPool.SetMaxThreads(10, 100);
        string[] asins;

        string[] lines = System.IO.File.ReadAllLines(@"C:\Users\Joe T\Desktop\AmazonAsins.csv");

        using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"\\WIN-UWPWZ7Z3RKX\wwwroot\repricer\WriteLines2a.txt"))
            file.WriteLine("Product-ID\tPrice1\tPrice2\tRank\tAFN\t" + DateTime.Now);
        prices = new string[lines.Length, 2];
        int i = 0;
        asins = new string[lines.Length];

        foreach (string line in lines)
        {
            scraping s = new scraping();


            char[] tabs = { '\t' };
            string asin;
            string[] words = line.Split(tabs);
            asin = words[1];
            asins[i] = asin;

            Thread.Sleep(1000);
            ThreadPool.QueueUserWorkItem(new WaitCallback(s.scraping1), asin);

            ++i;


        }


        return asins;
    }

Scraping Class

     public void scraping1(object a)
    {
        string AFN = "N";

        string asin = (string)a;

        double price, price2;
        string sprice;
        string context;
        string page = "*****" + asin;
        try
        {
            WebZinc WebZincProduct = new WebZinc();
            WebZincProduct.OpenPage(page);

            context = WebZincProduct.CurrentPage.Text;
        }
        catch
        {
            scraping1(a);
            return;
        }

        Regex regex11 = new Regex("****\r\n((.|\n)*?)****",
            RegexOptions.IgnoreCase);
        Match oP1 = regex11.Match(context);

        if (oP1.Value.Contains("*******"))
        {
            AFN = "Y";
        }
        Regex reg = new Regex(@"[0-9]+\.[0-9]+");
        MatchCollection mc = reg.Matches(oP1.Value);


        double cost = 0.0;
        double cost2 = 0.0;
        double shipping2 = 0.0;
        double shipping = 0.0;
        int j = 0;
        int j3 = 0;

        foreach (Match m in mc)
        {
            if (j == 0) cost = Convert.ToDouble(m.Value);
            if (j == 1) shipping = Convert.ToDouble(m.Value);
            Console.WriteLine("{0}", m.Value);
            ++j;
        }


        Regex regex4 = new Regex("****\r\n\r\n((.|\n)*?)****",
            RegexOptions.IgnoreCase);
        Match oP4 = regex4.Match(context);

        MatchCollection mc4 = reg.Matches(oP4.Value);

        foreach (Match m in mc4)
        {
            if (j3 == 0) cost2 = Convert.ToDouble(m.Value);
            if (j3 == 1) shipping2 = Convert.ToDouble(m.Value);
            Console.WriteLine("{0}", m.Value);
            ++j3;
        }



        price2 = cost2 + shipping2;
        price = cost + shipping;
        if (price == 0.0 && i != 5)
        {
            scraping1(a);
        }



        string rank = rankAFN(asin);
        lock (Program._locker)
        {

                using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"\\WIN-UWPWZ7Z3RKX\wwwroot\repricer\WriteLines2a.txt", true))
                    file.WriteLine(asin + "\t" + price + "\t" + price2 + "\t" + rank + "\t" + AFN);

    }
}
  • 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-24T23:57:20+00:00Added an answer on May 24, 2026 at 11:57 pm

    Here’s my best guess based on the fact that you have a LOT of extra code here that we can’t possibly interpret without seeing the whole code (which is why it’s best to post the most minimal example that recreates the issue as Jon Skeet so wonderfully articulated in his blog post Writing the Perfect S.O. Question).

    But here’s my guess. I’m guessing, and feeling pretty strongly, that you have runaway recursion here. Your method scrapping1() makes recursive calls to itself on exceptions and certain conditions that are not interpreted from the parameters.

    Because these recursive calls are depending on local variables or actions and not a parameter, it makes it VERY hard to safely control what recursion will do and you should probably not be making them in this case.

        catch
        {
            // recursion here passing the SAME arg, what is to stop this?
            scraping1(a);
            return;
        }
    

    And

        // WHERE does this 'i' come from?  I don't see where it's incrementing!
        // possible unsafe recursion...
        if (price == 0.0 && i != 5)
        {
            // recursion here passing the SAME arg, no stop condition?
            scraping1(a);
        }
    

    Another thing you can do would be to surround your scraping1() method’s body with a try/catch so that you can at least see the exception on screen and know what line its happening in.

     public void scraping1(object a)
     {
         try 
         {
              // your method logic
         }
         catch (Exception ex)
         {  
              Console.WriteLine(ex);
              Console.Out.Flush();
         }
    }
    

    If it is recursion, though, causing a StackOverflowException, the CLR will terminate your process. In that case comment out those recursive calls and think of what you’re really trying to do. I don’t think you really want to do recursion in this case. Are you just trying to “retry?”

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

Sidebar

Related Questions

I have a big application written in Visual Basic 6 and I need to
I have a basic ajax application, which will not work, instead the php code
I have a basic C# console application that reads a text file (CSV format)
I'm writing a basic planet viewer OpenGL Perl application, just for fun. I have
I'm trying to build a basic application which will have 2 separate components which
I am experimenting with Java Web Start. I have just written a basic JApplet
I have a basic quiz/survey type application I'm working on, and I'd like to
I have a website running a basic ASP.NET application that is mostly used from
I have an application where I need to use 'Basic Authentication'; however, in order
I have build a basic blog application, where an admin can write the article

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.