[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Automation server with events

Posted on 2005-04-20
8
Medium Priority
?
195 Views
Last Modified: 2010-04-16
Hello!

I'm trying to develop a small automation dll server in C#.

Everything was fine until I got to events, which I was unable to do.

What I did, was something like :

File | New Project...
Selected "Class Library"
Some of the code was :

// Properties
public string SetEquipmentName
            {
                  set
                  {
                        strEquipmentName = value;
                  }
            }

// Methods
public void Initialize()
            {
                  try
                  {
                        MessageBox.Show ("Initialize");
                  }
                  catch (Exception e)
                  {
                  }
            }


// etc...

This is working fine with the clients, but I need to do throw events like :

void OnEquipmentConnect()
void OnEquipmentDisconnect (int ErrorCode, ref string ErrorText)

etc.

Please help me.

Thank you

Joao
0
Comment
Question by:jpcs
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:Razzie_
ID: 13824982
In your namespace, declare the delegates:

public delegate void OnEquipmentConnect();
public delegate void OnEquipmentDisconnect(int ErrorCode, string ErrorText);

in your class, declare the events:

public event OnEquipmentConnect Connect;
public event OnEquipmentDisconnect Disconnect;

and somewhere in your code, use:

public void Connect() // or some other method you have that does the connecting part
{
    if(this.Connect != null)
        this.Connect();
}


and do the same for the Disconnect Event.

This should work - you can now use something like:

Automation.Server server = new Automation.Server();
server.Connect += new OnEquipmentConnect(server_Connect);

private void server_Connect()
{
    // your code here
}


That's about I think.
HTH,

Razzie
0
 
LVL 1

Author Comment

by:jpcs
ID: 13825895
Hello Razzie,

I'm sorry but this didn't work.


I forgot to mention one thing that might be important...

The client application is writte in VB or Delphi or C++ Builder


Regards,

Joao
0
 
LVL 1

Author Comment

by:jpcs
ID: 13832376
Well,

looks like I've found the answer to my question here : http://www.gekko-software.nl/DotNet/BigStory/AutomationInDotNet.htm

Hope this helps someone!


Thanks for the help.

Joao
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 8

Expert Comment

by:Razzie_
ID: 14002495
I kinda misread the question, the author solved it, so I say PAQ / Refund.
0
 
LVL 1

Author Comment

by:jpcs
ID: 14003789
Thanks Razzie_

Joao
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 14080902
PAQed with points refunded (250)

modulo
Community Support Moderator
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Screencast - Getting to Know the Pipeline
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question