Automation server with events

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
LVL 1
jpcsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Razzie_Commented:
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
jpcsAuthor Commented:
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
jpcsAuthor Commented:
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
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

Razzie_Commented:
I kinda misread the question, the author solved it, so I say PAQ / Refund.
jpcsAuthor Commented:
Thanks Razzie_

Joao
moduloCommented:
PAQed with points refunded (250)

modulo
Community Support Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.