using WriteNotifyEventHandler with tracefiles

I've a fined tuned trace running that outputs the result to a tracefile. Currently I'm using the TraceTable class to read back the trace, which works fine. However I'm trying to use the WriteNotify event to react when this file changes, but it never appears to fire. I'm using the beta2 of SQL 2005, does this work in it? Would anyone having a working example if it does?

Thanks,
Cathal

[404 byte] By [CathalConnolly] at [2008-2-4]
# 1
Cathal,
First of all, I assume you are using TraceFile class, since you are talking about reading and writing to and from a file.
Second, the WriteNotify event is triggered only when trace events are written to the file. It means you have to have a TraceFile object initialized as writer with another trace source attached to it, either a TraceServer object or another file or table. You can than call Write method in a loop. Each time it is called a WriteNotify event is raised and you have a chance to see and possibly modify trace event before it is written.

I hope that helps.

Regards,
Maciek Sarnowicz
SQL Server SDE

MaciekSarnowicz at 2007-9-9 > top of Msdn Tech,SQL Server,SQL Server SMO/DMO...
# 2
Thank you Maciek, I was (stupidly) trying to do it all with 1 TraceFile, your suggestion worked fine.

Cathal

CathalConnolly at 2007-9-9 > top of Msdn Tech,SQL Server,SQL Server SMO/DMO...

SQL Server

Site Classified