L
lightdoll
hello everyone
i want to know how to make a event by C# like ATL Sink.
The Event will be fired to C, C++, VB.
this below is my code, so i want to append a event function.
Could you help me make a Event function?
Thank you.
namespace TestServiceComponet
{
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[Guid("4b3b9bfe-304b-4a5c-ad7f-a1472fdcd41f")]
public interface ISingleton
{
int Foo();
bool Variant(object VarData);
}
[JustInTimeActivation]
[ObjectPooling(Enabled=true, MinPoolSize=1, MaxPoolSize=1,
CreationTimeout=5000)]
[Guid("e57cd005-f67e-44a0-99e4-9c1032c4420a")]
[ProgId("SomeOnes.Singleton")]
[ComVisible(true)]
public sealed class Singleton : ServicedComponent, ISingleton
{
public Singleton () {}
public int Foo()
{
return SingleInstance.instance.GetFoo();
}
public bool Variant(object VarData)
{
return SingleInstance.instance.Variant(VarData);
}
}
public sealed class SingleInstance
{
int i;
public static readonly SingleInstance instance = new
SingleInstance();
public SingleInstance(){}
public int GetFoo()
{
return ++i;
}
public bool Variant(object VarData)
{
/* int nTest;
string[] strTest = new string[3];
nTest = (int)((object[])(VarData))[0];
strTest[0] = (string)((object[])(VarData))[1];
strTest[1] = (string)((object[])(VarData))[2];
strTest[2] = (string)((object[])(VarData))[3];
Console.WriteLine("{0}, {1}, {2}, {3}", nTest, strTest[0],
strTest[1], strTest[2], strTest[3]);*/
// Console.WriteLine("{0}", (string)((object[])(VarData))[0]);
// MessageBox.Show((string)((object[])(VarData))[0]);
System.Diagnostics.Debugger.Break();
return true;
}
}
i want to know how to make a event by C# like ATL Sink.
The Event will be fired to C, C++, VB.
this below is my code, so i want to append a event function.
Could you help me make a Event function?
Thank you.
namespace TestServiceComponet
{
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
[Guid("4b3b9bfe-304b-4a5c-ad7f-a1472fdcd41f")]
public interface ISingleton
{
int Foo();
bool Variant(object VarData);
}
[JustInTimeActivation]
[ObjectPooling(Enabled=true, MinPoolSize=1, MaxPoolSize=1,
CreationTimeout=5000)]
[Guid("e57cd005-f67e-44a0-99e4-9c1032c4420a")]
[ProgId("SomeOnes.Singleton")]
[ComVisible(true)]
public sealed class Singleton : ServicedComponent, ISingleton
{
public Singleton () {}
public int Foo()
{
return SingleInstance.instance.GetFoo();
}
public bool Variant(object VarData)
{
return SingleInstance.instance.Variant(VarData);
}
}
public sealed class SingleInstance
{
int i;
public static readonly SingleInstance instance = new
SingleInstance();
public SingleInstance(){}
public int GetFoo()
{
return ++i;
}
public bool Variant(object VarData)
{
/* int nTest;
string[] strTest = new string[3];
nTest = (int)((object[])(VarData))[0];
strTest[0] = (string)((object[])(VarData))[1];
strTest[1] = (string)((object[])(VarData))[2];
strTest[2] = (string)((object[])(VarData))[3];
Console.WriteLine("{0}, {1}, {2}, {3}", nTest, strTest[0],
strTest[1], strTest[2], strTest[3]);*/
// Console.WriteLine("{0}", (string)((object[])(VarData))[0]);
// MessageBox.Show((string)((object[])(VarData))[0]);
System.Diagnostics.Debugger.Break();
return true;
}
}