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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:39:46+00:00 2026-05-20T10:39:46+00:00

I have an Application in C#/Winforms that is basically used to run test for

  • 0

I have an Application in C#/Winforms that is basically used to run test for customers accounts in a specific order/setup. They are all tests run in browsers and so I built it so it would automate the process since there are about 10-12 tests that need to be ran everytime a customer account is pulled up.

Basically what happens is you input the account number then it runs the tests.

Here’s a sample code.

public void startTestProcess()
    { 
        if (!cancelTests)
        {
            testRunning = true;
            var tabPage = createTabPage(banToRun, Convert.ToInt32(banToRun));
            loadingBox.Visible = true;
            mainTabControl.TabPages.Insert(0, tabPage);
            mainTabControl.SelectedTab = mainTabControl.TabPages[0];
            runTest(tabPage, banToRun);
            loadingBox.Visible = false;
        }
    }

private void runTest(TabPage t, string ban)
    {
        if (!cancelTests && !cancelCurrentOnly)
        {
            var tC = createInitialTabControl();
            t.Controls.Add(tC);
            int[] theTests = profileInfo.getSetList;
            for (int i = 0; i < theTests.Length; i++)
            {
                if (!cancelTests && !cancelCurrentOnly)
                {
                    var newTab = createTabPage(urlStrings.getName(theTests[i]), theTests[i]);
                    tC.TabPages.Add(newTab);
                    var webBrowser = createBrowser(urlStrings.getUrl(theTests[i], ban));
                    newTab.Controls.Add(webBrowser);
                    if (theTests[i] != 0 && theTests[i] != 1 && theTests[i] != 6
                        && theTests[i] != 11 && theTests[i] != 12)
                    {
                        if (!webBrowser.IsDisposed)
                        {
                            try
                            {
                                while (webBrowser.ReadyState != WebBrowserReadyState.Complete)
                                {
                                    Application.DoEvents();
                                }
                            }
                            catch
                            {
                                //Do Nothing
                            }
                        }
                    }
                    IntPtr pHandle = GetCurrentProcess();
                    SetProcessWorkingSetSize(pHandle, -1, -1);
                }
            }
        }
        if (cancelCurrentOnly)
        {
            cancelCurrentOnly = false;
        }
        banToRun = string.Empty;
        testRunning = false;

    }

So basically my question is, how can I optimize what I have in order to

A. Reduce lag/freezing – Note: Already implemented a way of forcing garbage collection after each test is run.
B. Improve performance of the WebBrowser controls possibly? – Already tried some webbrowser alternatives like WebKit for C# Wrapper (does not work on all tests due to some ajax based coding i believe)
C. Maybe implement multi-threaded operations. Not sure how i’d go about this without having cross-threaded exceptions thrown.

Thanks for your assistance. If you have any other questions feel free to ask.

  • 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-20T10:39:47+00:00Added an answer on May 20, 2026 at 10:39 am

    The lag / freezing issue is caused by you not using multiple threads; therefore all of the test runs are using the UI thread, so the UI cannot respond while the tests are being run.

    If the reason you are not using a backround worker(s) is that your are worried about having cross-threaded exceptions thrown, then you just need to make sure you are properly passing information between your threads (as opposed to avoiding multithreading altogether).

    Update

    This question addresses the issue of updating the UI based on workers’ progress.

    As a side note, you should not have to force garbage collection; most of the time, this will actually decrease performance. The garbage collector is specifically designed to collect when it has availability to do so (when the CPU is available). Forcing it to run takes cycles away from the real work your app is trying to do.

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

Sidebar

Related Questions

We have a big winforms C# application, that's basically a frontend for some databases
I have a winforms application that normally is at about 2-4% CPU. We are
I have C# winforms application that needs to start an external exe from time
I have a winforms application that presently ships with a chm file for context-sensitive
I have a winforms application that is doing the following: on each query: Db
I have an winforms application that was built using MVC. The controller is subscribing
I have a desktop (winforms) application that uses a Firebird database as a data
I have a .net 3.5 WinForms application that runs fine on my machine, but
We have a WinForms application written in C# that uses the AxAcroPDFLib.AxAcroPDF component to
I have a WinForms application (I'm using VB) that can be minimized to the

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.