jpcs
asked on
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
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
ASKER
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
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
ASKER
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
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
I kinda misread the question, the author solved it, so I say PAQ / Refund.
ASKER
Thanks Razzie_
Joao
Joao
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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_
private void server_Connect()
{
// your code here
}
That's about I think.
HTH,
Razzie