Questions tagged as 'singleton'

3
answers

How do objects created following singleton work?

I would like to understand how objects created following the singleton design pattern work in javascript. My main doubts are about the methods and attributes of this object, where and how to create them, and where and how to access them. I...
asked by 24.12.2015 / 19:23
2
answers

Singleton in JavaScript

How to implement the Singleton pattern in JavsScript in a simple and correct way - what assures me that the instance will be unique? I've seen some rather complex implementations, but would not that be enough? var xyz = xyz || (function (){...
asked by 15.11.2014 / 19:12
2
answers

How to apply the Singleton pattern correctly?

The class PEHandlerService needs to have a single instance and I do not want to use synchronized because of the slowness, I created the following code: public class PEHandlerService extends PlanilhaHandler { private LanguageH...
asked by 27.03.2015 / 13:19
3
answers

How to allow only one instance of a given class?

If we run the code below, a window with a button inside will be created, which whenever clicked will open another window (Window2). How can I make a second instance of Window2 not be allowed? I want to do this without using modal (). #!/usr/bi...
asked by 01.07.2014 / 19:42
1
answer

How to create a variable accessible in all forms?

In my application you will have a Login system. I want to create a variable to store the id of the user that is logged in, and that it can be accessed on all other forms. I need this because in my database, each table has a field called us...
asked by 05.01.2017 / 20:11
1
answer

Is there a pattern similar to Singleton?

It's really frustrating, a bit interesting maybe, but frustrating above all, I still figured out how and why to use the Singleton standard yesterday, and today, when I was going to finish a little improvement on a project, the true face of the...
asked by 14.11.2015 / 05:00
1
answer

Single instance of Class C #

I have a Windows Form with the following code: public partial class frmCadastroPessoaFisica : Form { public frmCadastroPessoaFisica() { InitializeComponent(); } } I would like to create only one instance of this form....
asked by 15.07.2016 / 14:14
2
answers

Keyword for C # equivalent to "synchronized" Java

Problem I'm implementing a connection manager that implements the standard Singleton , managing a pool of single-key connections for each new connection. So I'm trying to get problems with the parallelism of my manager, because it can be c...
asked by 17.08.2016 / 13:53
1
answer

Firebird C # singleton pattern

I'm using the following function to connect to the database, I'm programming in C # in Visual Studio 2013. namespace WindowsFormsApplication1 { static class Conexao { private static String strConn = Properties.Settings.Default...
asked by 03.11.2015 / 15:23
1
answer

Singleton pattern causes error: Using $ this when not in object context

I made this Singleton pattern that I saw on a site and found it great, well what I wanted. However something is going wrong because I have the error: Fatal error: Uncaught Error: Using $this when not in object context in /opt/lampp/htdocs/mysc...
asked by 04.10.2017 / 21:12