Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Singleton Classes

Singleton Classes

Scheduled Pinned Locked Moved ASP.NET
helpquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    robert110
    wrote on last edited by
    #1

    Hello everyone: Would you be able to give me some practical examples as to where I would need to implement Singleton classes? For e.g. if you could point out the scenarios where I must or should implement a Singleton class etc. I sure would appreciate your help. Thanks in advance. Regards, Robert

    C 1 Reply Last reply
    0
    • R robert110

      Hello everyone: Would you be able to give me some practical examples as to where I would need to implement Singleton classes? For e.g. if you could point out the scenarios where I must or should implement a Singleton class etc. I sure would appreciate your help. Thanks in advance. Regards, Robert

      C Offline
      C Offline
      CWIZO
      wrote on last edited by
      #2

      Singelton classes are used when you wan't to have only one instance of a class.

      -------------------------------------------------------- My portfolio & development blog Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!

      R 1 Reply Last reply
      0
      • C CWIZO

        Singelton classes are used when you wan't to have only one instance of a class.

        -------------------------------------------------------- My portfolio & development blog Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!

        R Offline
        R Offline
        robert110
        wrote on last edited by
        #3

        Dear CWIZO: Thanks a lot for your reply; I understand the concept of Singleton classes but for some reason I am unable to identify the scenario where I would need just one instance of a class. In other words 'why' would I need to have just one instance of a class? A practical (real world) example will be highly appreciated:). Thanks again. Regards, Robert

        C 1 Reply Last reply
        0
        • R robert110

          Dear CWIZO: Thanks a lot for your reply; I understand the concept of Singleton classes but for some reason I am unable to identify the scenario where I would need just one instance of a class. In other words 'why' would I need to have just one instance of a class? A practical (real world) example will be highly appreciated:). Thanks again. Regards, Robert

          C Offline
          C Offline
          CWIZO
          wrote on last edited by
          #4

          Well once could be a class for logging application errors. Since you don't wan't two clases write to the same file at once you make a singelton class.

          -------------------------------------------------------- My portfolio & development blog Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!

          E 1 Reply Last reply
          0
          • C CWIZO

            Well once could be a class for logging application errors. Since you don't wan't two clases write to the same file at once you make a singelton class.

            -------------------------------------------------------- My portfolio & development blog Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!

            E Offline
            E Offline
            eggsovereasy
            wrote on last edited by
            #5

            Maybe I'm way off base here, but wouldn't you either want multiple instances of this class so different threads don't change property data behind one another? Or maybe a static class so threads that need to log just call methods and pass the relevant data?

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups