I am sending a fucntion pointer. here is my Event Handler
Method. What is happening, is some how when my
eventhandler is fired it will lock up my program. I think
there is some memory issues here and I can't figure it
out.
unsafe public void EventHandler (void* vpUserData, uint
uiEvent, uint uiParam0, uint uiParam1)
{
EvQ[iQIn].uiUserData = (uint)vpUserData;
EvQ[iQIn].uiEvent = uiEvent;
EvQ[iQIn].uiParam0 = uiParam0;
EvQ[iQIn].uiParam1 = uiParam1;
richTextBox1.AppendText("\r\nEvent Handler " +
iQIn.ToString());
richTextBox1.AppendText("\r\nEvent : " + uiEvent.ToString
());
iQIn ++;
if(iQIn == 200) //Queue at max compacity
{
iQIn = 0; //Reset to 0
}
if(uiEvent == 215)
{
if(uiParam0== TONE_DIALTONE)
{
richTextBox1.AppendText("\r\n WE HAVE DIALTONE \r\n");
}
if(uiParam0 == TONE_RINGBACK)
{
richTextBox1.AppendText("\r\n WE HAVE RINGBACK \r\n");
}
if(uiParam0 == TONE_BUSY)
{
richTextBox1.AppendText("\r\n WE HAVE BUSY \r\n");
}
}
}
-----Original Message-----
Jim,
What is the mechanism that you are passing? Are you
passing a COMinterface pointer, or are you passing a function pointer
(which is marshaledfrom a delegate into unmanaged code)? Each way has its
own considerations,but both are certainly doable.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Jim" <je******@nationsfirstcorp.com> wrote in message
news:02****************************@phx.gbl... I have a windows application that is accessing unmanaged
code and providing a callback function that will create
events at unknown time spans. When the EventHandler
(callback function) fires it causes my program to crash
or freeze, or do strange stuff. When I remove this
callback function it works great. Problem is I need this
callback function to implement my state machine for the program
so I think I need to encapsulate this callback function
into its own process, but it takes 4 parameters. I have
looked all over the web, but cannot find a good example of this
implementation can anyone point me in a good direction?
.