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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:12:25+00:00 2026-06-01T16:12:25+00:00

Below is my entire class that I am using, I have two questions, 1

  • 0

Below is my entire class that I am using, I have two questions, 1 is this the proper use of Dispose() and also, why am I getting the error No Overload for method ‘dispose’ takes 1 argument.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Crawler
{
    class LoggingClass : IDisposable
    {
        public void GenericLogging(string systemMsg, string SystemClass, string SystemSection, string ID, string FixID, string baseURL, string mysqlQueryName, string mysqlQuery)
        {
            string Loggingall = " insert into tblLogs " +
                            "set SystemMsg='" + systemMsg.Replace("'","''") + "'" +
                            ",SystemClass = '" + SystemClass.Replace("'", "''") + "'" +
                            ",SystemSection = '" + SystemSection.Replace("'", "''") + "'" +
                            ",ID = '" + CarID.Replace("'", "''") + "'" +
                            ",FixID = '" + FixID.Replace("'", "''") + "'" +
                            ",baseurl = '" + baseURL.Replace("'", "''") + "'" +
                            ",mysqlqueryName = '" + mysqlQuery.Replace("'", "''") + "'" +
                            ",mysqlquery = '" + mysqlQuery.Replace("'", "''") + "'" +
                            ",TimeStamp = Now()";
            MySQLProcessing.MySQLProcessor MYSQLP = new MySQLProcessing.MySQLProcessor();
            MYSQLP.MySQLInsertUpdate(Loggingall, "Loggingall");
        }

        public void Dispose()
        {
            Dispose(true);
            // Take yourself off the Finalization queue 
            // to prevent finalization code for this object
            // from executing a second time.
            GC.SuppressFinalize(this);
        }
    }
}

Here is my updated code:
}

Is this the correct way to call it? Do i also have to call the dispose?

  • 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-01T16:12:26+00:00Added an answer on June 1, 2026 at 4:12 pm

    As other answerers have mentioned, it doesn’t look like you need to implement IDisposable. You have no class fields at all, so there’s nothing to clean up.

    Assuming there’s more to the class than you’ve shown, you’re following the pattern for implementing IDisposable, but you’re only halfway done.

    The pattern is to have IDisposable.Dispose() and the finalizer (~LoggingClass) both call a common method, Dispose(bool). In the Dispose(bool) method, you should clean up both managed and unmanaged resources if the boolean is passed true, and only clean up the unmanaged resources if passed false.

    Here’s the code I use for implementing IDisposable.

    ~LoggingClass()
    {
        this.Dispose(false);
    }
    
    protected bool Disposed { get; private set; }
    
    public void Dispose()
    {
        this.Dispose(true);
        GC.SuppressFinalize(this);
    }
    
    protected virtual void Dispose(bool disposing)
    {
        if (!this.Disposed)
        {
            if (disposing)
            {
                // Perform managed cleanup here.
    
            }
    
            // Perform unmanaged cleanup here.
    
            this.Disposed = true;
        }
    }
    

    Edit

    It looks like you added your updated code, and then removed it. But, here’s my comments on how you’re calling it.

    With the GenericLogging method as you currently have it, you don’t need IDisposable at all. However, there are a couple things I would do to improve up your code.

    1. Create the MySQLProcessing.MySQLProcessor instance in the
      constructor, rather than in the GenericLogging method.
    2. Call MySQLProcessing.MySQLProcessor.Dispose() (or .Close(), or
      whatever that class has) in the managed cleanup section of
      Dispose(bool).
    3. Keep your LoggingClass objects around longer. Yes, what you have
      demonstrated is a properly implemented using statement, but you’ll
      end up creating & destroying thousands of objects in your code.
      Create one LoggingClass object, and keep it around for the entire
      length of the program, not just for one log statement.
    4. Call LoggingClass.Dispose() when your application is about to exit. Do this manually (not with a using statement).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alrighty so below I have this script doing exactly what I want; I'm using
Below is my entire code from a User control that contains the YUI Uploader.
I need to echo entire content of included file. I have tried the below:
Below I have written a sample program that I have written to learn about
I have a div with class divItemclass for this class, I have put height
I have a design that uses two outer columns, and within one of the
Updated below . The following is the entire code I have in my main.cpp:
The code below plots some simple x-y data, but it has two problems that
I have three targets of which one is using java as shown below //
UPDATED: SEE BELOW I've been porting the code for this assignment: http://www.stanford.edu/class/cs221/progAssignments/PA1/search.html (the entire

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.