Events in ocx didn't raise in single thread apartment (STA)

145 views Asked by At

I tried to create an ocx control by code manually.(Because i need use this control in web application ,so I create a form application and use this control for test ) , current program is STA mode .

        AxC_FaceServerSdk axc = new AxCFaceServerSdkLib.AxC_FaceServerSdk();
        axc.CreateControl();
        axc.OnEventCConnect += delegate(object sender, _DFaceServerSdkEvents_OnEventCConnectEvent e)
        {
            MessageBox.Show("raised");
        };
        axc.C_ServerInit(30000, 0);

I think this control works normally since i saw linstener inside is working! But the event never raised !

Then tried another way :Drag ocx control into form , and use the following code :

        this.axC_FaceServerSdk1.C_ServerInit(30000, 0);
        this.axC_FaceServerSdk1.OnEventCConnect += delegate(object sender, _DFaceServerSdkEvents_OnEventCConnectEvent e)
        {
            MessageBox.Show("raised");
        };

Event raiesd !!

Anyone knows why ?

0

There are 0 answers