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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:25:43+00:00 2026-05-26T22:25:43+00:00

I have a base form that I use when calling 2 forms. Previously when

  • 0

I have a base form that I use when calling 2 forms. Previously when calling the forms I didn’t dispose of them, but I have found that reusing them, they would stay in memory and not get collected. So I have instead used a using statement instead to clear the memory, and all my problem are fixed.

But now a new problem arises, one that I had previously when testing my app with mono on Linux. I though it might be a mono specific problem, but since adding the using statement the same thing happens on my Windows machine. So it might just be that the Garbage Collector on Mono is different and was disposing properly of my forms.

Here is my problem I have a thread that I start to extract files in the background And I have progress bar telling me the progress, before using the dispose if I closed the form and reopened it my files extracted correctly and the progress bar was working fine. But now they work fine the first time, but if I reopen the form or the other one that has the same base, the extraction is not working, no files are extracted because I have a null exception when reporting the progress.

    private void ExtractFiles()
    {
        Zip.ExtractProgress += new EventHandler<ExtractProgressArgs>(Utils_ExtractProgress);
        Thread t = new Thread(new ThreadStart(Zip.ExtractZip));
        t.IsBackground = true;
        t.Start();
        FilesExtracted = true;
    }

    void Utils_ExtractProgress(object sender, ExtractProgressArgs e)
    {
        UpdateProgress(e.Pourcentage);
    }

    private delegate void UpdateProgressDelegate(int Pourc);
    private void UpdateProgress(int Pourc)
    {
        lock (this)
        {
            if (Progress.ProgressBar.InvokeRequired)
            {
                UpdateProgressDelegate del = new UpdateProgressDelegate(UpdateProgress);
                Progress.ProgressBar.BeginInvoke(del, Pourc);
            } else
            {
                Progress.Value = Pourc;

            }
        }
    }

This code is in my BaseForm, the Progress control isn’t null, but all of it’s properties have null exceptions. So when checking if Invoked is required it raises an Null exception.

Here is my Zip.Extract method

    public static event EventHandler<ExtractProgressArgs> ExtractProgress;
    static ExtractProgressArgs Progress;

    internal static void ExtractZip()
    {
        try
        {
            using (ZipFile zip = ZipFile.Read(Variables.Filename))
            {
                Progress = new ExtractProgressArgs();
                Progress.TotalToTransfer = Convert.ToInt32(zip.Sum(e => e.UncompressedSize));
                zip.ExtractProgress += new EventHandler<ExtractProgressEventArgs>(zip_ExtractProgress);
                Old = 0; New = 0;
                foreach (ZipEntry item in zip)
                {

                    item.Extract(Variables.TempFolder, ExtractExistingFileAction.OverwriteSilently);
                }
            }
        } catch (Exception)
        {
        }
    }

    static long Old;
    static long New;
    static void zip_ExtractProgress(object sender, ExtractProgressEventArgs e)
    {
        if (e.EventType == ZipProgressEventType.Extracting_EntryBytesWritten)
        {
            New = e.BytesTransferred;
            Progress.Transferred += New - Old;
            Old = e.BytesTransferred;

            if (ExtractProgress != null)
            {
                ExtractProgress(e.CurrentEntry, Progress);
            }

        } else if (e.EventType == ZipProgressEventType.Extracting_AfterExtractEntry)
        {
            Old = 0;
        }
    }

Might be because my Zip.Extract is static? I have almost no knowledge of multi-threading, like synchronization, etc.

  • 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-26T22:25:43+00:00Added an answer on May 26, 2026 at 10:25 pm

    The short answer is yes, some of your problems are due to the static nature of those operations.

    You should be able to resolve the problem by removing the static declarations from your Zip class and then creating an instance of it as needed.

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

Sidebar

Related Questions

I have a base User form that I am subclassing for each use case,
I have a namespace Company.UI.Forms where we have a form base class BaseForm that
I have a recursive method on the base form that takes in a control
In my windows forms project I have a parent form that is creates other
I have a base form. I place Ok and Cancel buttons on the bottom
Say I have a base form of a word and a tag from the
I have a .NET c# form with a tabcontrol on the base form. This
In the project I'm working on now, we have base Entity class that looks
the problem is the following. We have a (rather large) code base in form
I have a search form that can search in different provider. I started out

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.