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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:22:30+00:00 2026-06-01T11:22:30+00:00

This is probably a newb question so i’ll come right out and say that.

  • 0

This is probably a newb question so i’ll come right out and say that. This is my first time creating an IDisposable class, I want to make sure that I created my class correctly, called it correctly, and Dispose of it correctly. Thanks!

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

namespace Crawler
{
    class LoggingClass
    {
        public class LoggingDisposeable : 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("'", "''") + "'" +
                                ",Site = 'AutoTrader'" +
                                ",TimeStamp = Now()";
                using (var MYSQLP = new MySQLProcessing.MySQLProcessor())
                {
                    MYSQLP.MySQLInsertUpdate(Loggingall, "Loggingall");
                }
            }

            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;
                }
            }

            protected bool Disposed { get; private set; }

        }
    }
}

And this is how I call it.

 var options = new ParallelOptions();
options.MaxDegreeOfParallelism = 5;
                Parallel.ForEach(urlTable.AsEnumerable(),options, drow =>
            {

using (var logClass = new LoggingClass.LoggingDisposeable()) { logClass.GenericLogging("ZipCode not available for this dealerL", "DealershipRequest", "checkExistingDealers", dealerID, "DealerShipZipCode",rDealerLink, "", ""); } }</pre>
  • 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-01T11:22:31+00:00Added an answer on June 1, 2026 at 11:22 am

    I think what you intend to do is something like this:

    public class LoggingDisposeable : IDisposable
    {
        MySQLProcessing MySQLP;
    
        public LoggingDisposeable()
        {
            MYSQLP = new MySQLProcessing.MySQLProcessor();
        }
    
        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("'", "''") + "'" +
                            ",Site = 'AutoTrader'" +
                            ",TimeStamp = Now()";
    
                MYSQLP.MySQLInsertUpdate(Loggingall, "Loggingall");                
        }
    
        public void Dispose()
        {
            MYSQLP.Dispose();
        }
    }
    

    Then use it like this:

    using (var logClass = new LoggingDisposeable())
    {
        var options = new ParallelOptions();
        options.MaxDegreeOfParallelism = 5;
        Parallel.ForEach(urlTable.AsEnumerable(), options, drow =>
            {
                logClass.GenericLogging("ZipCode not available for this dealerL", "DealershipRequest", "checkExistingDealers", dealerID, "DealerShipZipCode", rDealerLink, "", "");
            });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably a newb question but how do I call a model that
Probably a very newb C++ question. Say I have a class, vertex, with several
This is probably a newb question but...I was working on a db in SQSH
This is probably a total newb question but does anyone know how to make
Ok, I know this is probably a pretty newb question, but when it comes
This is probably a newb question. How does a chat server like PHPFreeChat Works?
Now this probably seems a little stupid at first, but I am creating a
I am very new to Cocoa and this is probably a complete newb question.
I've been pulling my hair out with this all day. Probably a newb error
this probably is a basic question, but can I do something like this: Class

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.