Need help with event in thread

Hi,

I have a TDI client driver which has a thread sending watch packets to
another application.
If the driver doesn’t receive an acknowledge in time, it assumes the
connection is lost (by example when I unplug the network cable).
However when it goes in the Disconnect() function and calls
IoCallDriver(), I have the following error:

*** Assertion failed: (Event)->Header.Type == NotificationEvent ||
(Event)->Header.Type == SynchronizationEvent
*** Source File: w:\nt\private\ntos\ke\up..\eventobj.c, line 380

I doesn’t understand this error because the event is correctly initialized
and the thread runs at PASSIVE_LEVEL
Any help would be welcome… Below is the source code for the thread and
Disconnect() function

/*
* WatchThread
*/
VOID WatchThread(IN PDEVICE_EXTENSION Extension)
{
LARGE_INTEGER SleepTimeout;
ULONG Acknowledge;
NTSTATUS Status;

SleepTimeout.QuadPart=-10000L; // 1 ms
while(Extension->TacheVeille.Etat==THREAD_STATE_RUNNING)
{
if(KeReadStateTimer(&Extension->WatchTimer)==TRUE)
{
// Check connection
if(Extension->Connected==FALSE)
{

if((Status=Connect(Extension->Connection.Object,Extension->AdresseIp,

Extension->TcpPort,NULL,NULL))==STATUS_SUCCESS)
{
Extension->Connected=TRUE;
Extension->WatchAck=FALSE;
}
}
// Send watch packet
if(Extension->Connected==TRUE)
{
Status=SendWatch();
if(Status==STATUS_SUCCESS)
{
// Wait for Acknowledge
Acknowledge=0;
do
{

KeDelayExecutionThread(KernelMode,FALSE,&Extension->WatchTimeout);
Acknowledge++;
}
while(Acknowledge<=Acknowledge && Extension->WatchAck==FALSE);
if(Extension->WatchAck==TRUE)
Extension->WatchAck=FALSE;
else
{
Extension->Connected=FALSE;

Disconnect(Extension->Connection.Object,TDI_DISCONNECT_ABORT);
}
}
}
KeSetTimer(&Extension->WatchTimer,Extension->WatchTimeout,NULL);
}
KeDelayExecutionThread(KernelMode,FALSE,&SleepTimeout);
}
KeCancelTimer(&Extension->WatchTimer);
Extension->TacheVeille.Etat=THREAD_STATE_STOPPED;
PsTerminateSystemThread(STATUS_SUCCESS);
}

/*
* Disconnect
*/
NTSTATUS Disconnect(PFILE_OBJECT FileObject,IN ULONG Flags)
{
PIRP Irp;
KEVENT Event;
NTSTATUS Status;
IO_STATUS_BLOCK IoStatus;
PDEVICE_OBJECT DeviceObject;
LARGE_INTEGER WaitTimeout;

KeInitializeEvent(&Event,NotificationEvent,FALSE);
DeviceObject=IoGetRelatedDeviceObject(FileObject);
Irp=TdiBuildInternalDeviceControlIrp(TDI_DISCONNECT,DeviceObject,FileObject,&Event,&IoStatus);

if(Irp!=NULL)
{

TdiBuildDisconnect(Irp,DeviceObject,FileObject,NULL,NULL,NULL,Flags,NULL,NULL);

Status=IoCallDriver(DeviceObject,Irp);
if(Status==STATUS_PENDING)
{
WaitTimeout.QuadPart=-10000000L; // 1 s

Status=KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,&WaitTimeout);

}
}
else
Status=STATUS_INSUFFICIENT_RESOURCES;

return Status;
}