Hi Michael,
Thanks for your post.
Oh, I find my colleague Gary Chang[MSFT] has worked another issue
"Programmatically Find All Registry Entries" in this newsgroup. After
talking with him, I understand more context information regarding your
current project. Based on my understanding, you are writing a regedit style
winform application which implement registry search function. Now, you want
to implement Pause/Continue/Stop function in the "search engine". If I have
misunderstood you, please feel free to tell me, thanks.
First, in the "search engine", we should define the actual semantic of each
search operations: Pause, Continue and Stop. Normally, Pause operation
allows a search to "Continue" at a later time from the current position,
while "Stop" operation will terminate the current search operation
completely, it will not allow "Continue" anymore, we can only "restart" the
search function again from the start position.
So I assume your question lies with how to implement the "Pause/Continue"
properly.
Since registry is structured in a tree-style way like filesystem, the most
clear way to search it is using recurrsive search as you have known. The
breakout point in a recurrsive function invocation is checked by a "if"
statement, when the condition meets, such as the registry to search is
found. The common recommendation to implement the pause/continue is: once
the registry is found in the "if" statement in the recursion, you may
update the UI to notify the user. The current recurrsive search should not
return from the "if" statement, it should just wait/sleep in this "if"
statement for a further "continue" or "cancel"(abort the entire search
process) instructions from user. Since the recursion function return value
controlls whether the recursion should continue or break, so your
wait/sleep operation in the "if" statement should return corresponding
continue/break value based on the "continue" or "cancel" instructions
passed by user.
As a conclusion, the "Pause" operation can be implemented with a wait
operation in the "if" statement of recursion function, while "Continue"
operation can be implemented by returning a recursion continue meaning
value from the "if" statement. "Cancel" operation can be implemented by
returning a recursion terminate meaning value from the "if" statement.
Hope this explanation is clear. If you have any concern or anything
unclear, please feel free to tell me, thanks.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.