John G Duffy
October 23rd, 2001, 08:54 AM
I have a sample class module that has a While Wend loop in it that I can see no way to break out of and I am curious as to how this thing can be functional.
Here is the Routine. Someone here on this forum may recognize this snippet.
Hope you are not offended.
If mhPrinter = 0 then
'\ Need to get the printer handle for the printer device named
lRet = OpenPrinter(newName, mhPrinter, pDef)
'\ and start printer notification chain...
If mChangeNotificationHandle <> 0 then
Call FindClosePrinterChangeNotification(mChangeNotificationHandle)
End If
With pNotifyOptions
.Version = 2
End With
mChangeNotificationHandle = FindFirstPrinterChangeNotification(mhPrinter, PRINTER_CHANGE_ALL, 0, pNotifyOptions)
While true
DoEvents
If WaitForSingleObject(mChangeNotificationHandle, WAIT_REASONABLE) = STATUS_WAIT_0 then
RaiseEvent ChangeNotification
mChangeNotificationHandle = FindNextPrinterChangeNotification(mChangeNotificationHandle, pdwChange, pNotifyOptions, vbNull)
End If
Wend
End If
The While True ... Wend loop seems never to be satisfied. I can see no way to Satisfy the "True" expected condition. I realize DO ... Loop can perform similar functions but still my curiosity is peaked here.
John G
Here is the Routine. Someone here on this forum may recognize this snippet.
Hope you are not offended.
If mhPrinter = 0 then
'\ Need to get the printer handle for the printer device named
lRet = OpenPrinter(newName, mhPrinter, pDef)
'\ and start printer notification chain...
If mChangeNotificationHandle <> 0 then
Call FindClosePrinterChangeNotification(mChangeNotificationHandle)
End If
With pNotifyOptions
.Version = 2
End With
mChangeNotificationHandle = FindFirstPrinterChangeNotification(mhPrinter, PRINTER_CHANGE_ALL, 0, pNotifyOptions)
While true
DoEvents
If WaitForSingleObject(mChangeNotificationHandle, WAIT_REASONABLE) = STATUS_WAIT_0 then
RaiseEvent ChangeNotification
mChangeNotificationHandle = FindNextPrinterChangeNotification(mChangeNotificationHandle, pdwChange, pNotifyOptions, vbNull)
End If
Wend
End If
The While True ... Wend loop seems never to be satisfied. I can see no way to Satisfy the "True" expected condition. I realize DO ... Loop can perform similar functions but still my curiosity is peaked here.
John G