Click here to Skip to main content
16,016,178 members
Home / Discussions / C#
   

C#

 
GeneralRe: A Few Quick Questions Pin
BlitzPackage10-Jan-07 9:27
BlitzPackage10-Jan-07 9:27 
AnswerRe: A Few Quick Questions Pin
Ed.Poore10-Jan-07 8:01
Ed.Poore10-Jan-07 8:01 
GeneralRe: A Few Quick Questions Pin
BlitzPackage10-Jan-07 9:13
BlitzPackage10-Jan-07 9:13 
AnswerRe: A Few Quick Questions Pin
atulonweb@hotmail.com11-Jan-07 23:12
atulonweb@hotmail.com11-Jan-07 23:12 
QuestionExcel.Workbooks.Open() with different Excel versions Pin
Ali Nehring10-Jan-07 5:08
Ali Nehring10-Jan-07 5:08 
AnswerRe: Excel.Workbooks.Open() with different Excel versions Pin
ednrgc10-Jan-07 6:37
ednrgc10-Jan-07 6:37 
QuestionRe: Excel.Workbooks.Open() with different Excel versions Pin
Ali Nehring11-Jan-07 4:35
Ali Nehring11-Jan-07 4:35 
QuestionSharing events with multiple programs Pin
aalex67510-Jan-07 4:54
aalex67510-Jan-07 4:54 
I am trying to write a DLL that has an event and am subscribing to the event from 2 different programs, but each of my programs is creating a new instance of the DLL.

The class is a singleton class and looks like this:
public sealed class clsEvents
{
  // Create a new Singleton Instance of the class
  public static readonly clsEvents Instance = new clsEvents();

  private string _Value = "";
  public event EventHandler ValueChanged;

  public void OnValueChanged(EventArgs e)
  {
    EventHandler handler = ValueChanged;
    if (null != handler)
    {
      handler(this, e);
    }
  }

  public string Value
  {
    get { return _Value; }
    set
    {
      _Value = value;
      OnValueChanged(EventArgs.Empty);
    }
  }
}
The singleton class only does half the work so that the same instance of the class is shared within each program but I need to use the same instance in both programs. I have set both programs to compile into the same directory so I know they are loading the same DLL but they are each creating their own instance of the class.

Finally, my question:
In VB6 it is possible to set the Instancing of a DLL to Multiuse and any programs that use that DLL would share the same global variables from the DLL. Is it possible to do the same thing in C# so that each of my programs uses the same instance of the singleton class?

Forgive me if I am going about this all wrong but hopefully someone can help. Please tell me if there is a better way to share events across multiple programs.
AnswerRe: Sharing events with multiple programs Pin
Rob Philpott10-Jan-07 5:08
Rob Philpott10-Jan-07 5:08 
AnswerRe: Sharing events with multiple programs Pin
Alaric_10-Jan-07 8:37
professionalAlaric_10-Jan-07 8:37 
GeneralRe: Sharing events with multiple programs Pin
Alaric_10-Jan-07 8:40
professionalAlaric_10-Jan-07 8:40 
QuestionHow to get Value of An Object? Pin
EntManager10-Jan-07 4:37
EntManager10-Jan-07 4:37 
AnswerRe: How to get Value of An Object? Pin
Martin#10-Jan-07 4:42
Martin#10-Jan-07 4:42 
GeneralRe: How to get Value of An Object? Pin
Pete O'Hanlon10-Jan-07 4:50
mvePete O'Hanlon10-Jan-07 4:50 
GeneralRe: How to get Value of An Object? Pin
EntManager10-Jan-07 4:51
EntManager10-Jan-07 4:51 
QuestionObject Pin
Civic0610-Jan-07 4:29
Civic0610-Jan-07 4:29 
AnswerRe: Object Pin
ednrgc10-Jan-07 4:32
ednrgc10-Jan-07 4:32 
AnswerRe: Object Pin
Ravi Bhavnani10-Jan-07 4:33
professionalRavi Bhavnani10-Jan-07 4:33 
AnswerRe: Object Pin
Colin Angus Mackay10-Jan-07 4:34
Colin Angus Mackay10-Jan-07 4:34 
QuestionTrouble in parameter! Pin
nclauder10-Jan-07 4:04
nclauder10-Jan-07 4:04 
AnswerRe: Trouble in parameter! Pin
Colin Angus Mackay10-Jan-07 4:17
Colin Angus Mackay10-Jan-07 4:17 
AnswerRe: Trouble in parameter! Pin
Alaric_10-Jan-07 7:09
professionalAlaric_10-Jan-07 7:09 
GeneralRe: Trouble in parameter! Pin
Colin Angus Mackay10-Jan-07 10:20
Colin Angus Mackay10-Jan-07 10:20 
GeneralRe: Trouble in parameter! [modified] Pin
Alaric_10-Jan-07 10:42
professionalAlaric_10-Jan-07 10:42 
QuestionCheck for Filesystem Type NTFS / FAT .NET 1.1 [modified] Pin
Thomas Mihatsch10-Jan-07 3:49
Thomas Mihatsch10-Jan-07 3:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.