public void Fire() { if (source.Any()) { return; } if (!batchEvents) { // managedToIWbem(o, writeDWORD1, writeQWORD1); toWMI(o, /*xoa1[0]*/ oa1test.realInterfaces[0]); source.pSink.Indicate_(1, oa1test.realPointer); // int j = Indicate(3, source.ipSink, 1, oa1test.realPointer); } else { lock (this) { // managedToIWbem(o, writeDWORD[currentIndex], writeQWORD[currentIndex++]); toWMI(o, /*xoa[currentIndex++]*/ oatest.realInterfaces[currentIndex++]); if (cleanupThread == null) { int tickCount = Environment.TickCount; if (tickCount - lastFire < 1000) { cleanupThread = new Thread(new ThreadStart(Cleanup)); cleanupThread.ApartmentState = ApartmentState.MTA; cleanupThread.Start(); } else { source.pSink.Indicate_(currentIndex, oatest.realPointer); // Indicate(3, source.ipSink, currentIndex, oatest.realPointer); currentIndex = 0; lastFire = tickCount; } } else if (currentIndex == batchSize) { source.pSink.Indicate_(currentIndex, oatest.realPointer); // Indicate(3, source.ipSink, currentIndex, oatest.realPointer); currentIndex = 0; lastFire = Environment.TickCount; } } } }
// // [marioh, RAID: 123543] // Changed signature to account for [....] problems. // public void Fire(object o) { if (source.Any()) { return; } if (!batchEvents) { // lock (this) { convertFunctionNoBatch(o); // // Reuters VSQFE#: 750 [marioh] // At this point, the ToWMI method has been called and a new instance created. // We have to make sure the wbemObjects array (which is the array of IWbemClassObjects to be indicated) // is updated to point to the newly created instances. // wbemObjects[0] = (IntPtr)fieldInfo.GetValue(convertFunctionNoBatch.Target); source.IndicateEvents(1, wbemObjects); } } else { lock (this) { convertFunctionsBatch[currentIndex++](o); // // Reuters VSQFE#: 750 [marioh] // At this point, the ToWMI method has been called and a new instance created. // We have to make sure the wbemObjects array (which is the array of IWbemClassObjects to be indicated) // is updated to point to the newly created instances. // wbemObjects[currentIndex - 1] = (IntPtr)fieldInfo.GetValue(convertFunctionsBatch[currentIndex - 1].Target); if (cleanupThread == null) { int tickCount = Environment.TickCount; if (tickCount - lastFire < 1000) { lastFire = Environment.TickCount; cleanupThread = new Thread(new ThreadStart(Cleanup)); cleanupThread.SetApartmentState(ApartmentState.MTA); cleanupThread.Start(); } else { source.IndicateEvents(currentIndex, wbemObjects); currentIndex = 0; lastFire = tickCount; } } else if (currentIndex == batchSize) { source.IndicateEvents(currentIndex, wbemObjects); currentIndex = 0; lastFire = Environment.TickCount; } } } }