Design and Deployment of C# Programs

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • desigan
    New Member
    • Sep 2006
    • 7

    Design and Deployment of C# Programs

    Hi All,

    I am new to C# and I am facing a problem with respect to design and deployment of C# program.

    My application needs the following:
    a) A console program will do some data processing and will store the results in a static variable in Singleton class.
    [Imagine the logic like this - This program takes the list of absent employees and find their emailids from a database and store the emailids in a static variable in Singleton class.
    Once this is done, the console program starts a timer program. The timer program will take the emailid from the static variable and sends email to those employees once in every one hour - "Are you coming to office or not?"]

    b) A GUI program will have one button and on clicking the button, it will access the same static variable in Singleton class.
    [
    Imagine the logic like this - This GUI allows an administrator to enter an email id in a textbox. Then, the administrator will click the "Add" button. Then, this emailid will be added to the existing list of emailids in the static variable in same Singleton Class.
    So, my timer program in (a) will consider this newly added emailid too, when it sends email in the next hour.
    ]

    I am facing the following problem when I try to develop the same. I am not able to access the same static memory variable from GUI program.

    In java (if it is a web-based application), we deploy the application in a server and the static variable will be held in memory by the server. So, whichever client request for the variable, server will ensure that it gives the same variable to all. But, I dont know how to do it in C#.

    I am using Visucal C# Express Edtion (as of now) for development. I develop it as a project in this IDE under a solution. I am also unable to bring these two programs into a single project. It is because, both of my programs need a Main() method.

    Can someone help me out? How to bring these two programs together to access same variable? Thanks.......

    Kindly let me know if anymore details are required.

    Regards,
    Desigan

    Note: I request you not to validate the logic of my example. It is not my requirement, but mimics the problem that I am facing.
  • polygonVB
    New Member
    • Sep 2006
    • 15

    #2
    Maybe I'm not understanding, but if you declare the singleton class as a global variable wouldn't that make all of its properties globally accessible?

    Singleton o;
    private void()
    {
    o = new Singleton;
    o.LocalVariable = AllAbsentPeople ;
    }
    private AddUser()
    {
    o.LocalVariable = AllAbsentPeople + NewAbsentPerson
    }


    Recently I've only been programming in VB.net so you'll have to excuse my syntax.

    Paul

    Comment

    • desigan
      New Member
      • Sep 2006
      • 7

      #3
      Hi,

      Thanks for the reply.

      This is the problem that I face in short. I have a singleton class and in that there is a global variable. Of course (as you mentioned), this variable is accessible by any classes.

      Now, my application has
      - a console application that updates this variable
      - a GUI which also update the same variable

      Now, console application works fine. Say, it has updated some value in that global variable. Now, when we run the GUI it does not consider the same variable. Instead it has its own copy of global variable. It behaves as if the program is run from a different runtime. But, I am running it from the same runtime.

      Regards,
      Desigan

      Comment

      Working...