Re: Dealing with AdvancedSearch and AdvancedSearchComplete

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Thanks for your help with this, Ken.
How can I tell if the events are executing quickly enough not to miss the
next event? Something to do with setting a System.Timer....? (Guess you can
tell I'm groping around blindly in the dark here...)

Thanks again
Brian


"Ken Slovak - [MVP - Outlook]" wrote:

> I can't answer the VSTO questions, I don't use it.
>
> One thing I'd suggest is maybe creating a collection and putting the synch
> complete handler in a class module. Then put the class into a collection so
> you have one class handler for each process you start. The collection will
> keep them all alive.
>
> Another thing to consider is whether your handler code executes quickly
> enough. It's possible that when you are in a handler that your code is
> taking enough time and you have complete events firing quickly enough that
> you are just missing some events. It's like with assembly code and handling
> interrupt requests, you need to execute quickly enough not to miss the next
> event.
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
> Reminder Manager, Extended Reminders, Attachment Options
> http://www.slovaktech.com/products.htm
>
>
> "blueinc" <blueinc@xxxxxxxxxxxxx> wrote in message
> news:4DE94D83-1243-4209-8BC1-A418ADD59376@xxxxxxxxxxxxxxxx
> > Thanks for the pointers, Ken. I *think* I'm handling them properly so far.
> > (code below)
> > What steps should I take to analyse what's going on? I'm developing in
> > VS2005 Beta 2 using the VSTO...The Debug.Print lines just aren't doing it
> > for me... :-)
> > Or should I be using the BeginInvoke and EndInvoke methods mentioned here:
> > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconasynchronousprogramming.asp
> > ?
> >
> > Thanks again,
> > Brian
> > 'form.load has:
> > AddHandler _app.AdvancedSearchComplete, AddressOf
> > _app_AdvancedSearchComplete
> > AddHandler _app.AdvancedSearchStopped, AddressOf
> > _app_AdvancedSearchStopped
> > 'searches sent here
> > Private Sub ProcessTopics(ByVal folderToCheck As Outlook.MAPIFolder, ByVal
> > FolderIndex As Integer)
> > Dim myEnumerator As IDictionaryEnumerator =
> > _hshTopics.GetEnumerator()
> > Dim foundFolder As Integer = 1
> > While myEnumerator.MoveNext()
> > foundFolder = CInt(myEnumerator.Key.Substring(0,
> > myEnumerator.Key.indexof("-")))
> > If FolderIndex = foundFolder Then
> > Dim scope As String = "'" & folderToCheck.FolderPath & "'"
> > scope += ", '" & strSentFolderPath & "'"
> > Dim filter As String = ""
> > filter = BuildFilterString(myEnumerator.Value)
> >
> > Dim tagline As String = myEnumerator.Key
> > Dim mySearch As Outlook.Search
> > Try
> > 'TODO: make this multi-threaded??
> > mySearch = _app.AdvancedSearch(scope, filter, False,
> > tagline)
> > _searchesSentCount += 1
> > 'Debug.Print("_searchesSentCount:" &
> > _searchesSentCount)
> >
> > Catch exCom As System.Runtime.InteropServices.COMException
> > _COMExceptionCount += 1
> > ReDim Preserve COMExceptions(_COMExceptionCount)
> > COMExceptions(_COMExceptionCount) = msg
> >
> > Catch exArgs As System.ArgumentException
> > _ARGExceptionCount += 1
> > ReDim Preserve ARGExceptions(_ARGExceptionCount)
> > ARGExceptions(_ARGExceptionCount) = msg
> >
> > Catch ex As Exception
> > MsgBox(ex.Message)
> > Finally
> > mySearch = Nothing
> >
> > End Try
> > End If
> > End While
> > End Sub
> > 'searches returned here
> > Sub _app_AdvancedSearchComplete(ByVal SearchObject As Outlook.Search)
> > Dim SearchResults As Outlook.Results = SearchObject.Results
> > _searchResultsCount += 1
> > Debug.Print("Start processing " & SearchObject.Tag.ToString)
> > 'Debug.Print("_app_AdvancedSearchComplete: _searchResultsCount:" &
> > _searchResultsCount)
> > Select Case SearchResults.Count
> > Case 0,1
> > 'ignore
> > Case Else
> > Try
> > Dim arrEmails As New ArrayList
> > Dim currentEmail As Outlook.MailItem =
> > SearchResults.GetFirst
> > If Not currentEmail Is Nothing Then
> > Do While Not currentEmail Is Nothing
> > arrEmails.Add(currentEmail)
> > currentEmail = SearchResults.GetNext
> > Loop
> > End If
> > If arrEmails.Count >= 2 Then
> > ProcessResults(arrEmails)
> > End If
> >
> > Catch exceptionNull As NullReferenceException
> > Debug.Print("exceptionNull")
> >
> > Catch ex As Exception
> > Debug.Print("General exception: " & ex.Message)
> >
> > End Try
> > End Select
> > Debug.Print("END processing of " & SearchObject.Tag.ToString)
> > If _searchResultsCount = _searchesSentCount Then
> > Debug.Print("Complete.")
> > Else
> > Debug.Print("END processing of " & SearchObject.Tag.ToString)
> > End If
> > SearchResults = Nothing
> > SearchObject = Nothing
> > End Sub
>
>
.



Relevant Pages

  • RXParse module v.90 (by robic0)
    ... When I release version 1 of RXParse, I anticipate that I will provide a ftp site ... sub original_content ... then call content handler with $content ... # call start tag handler with $2 ...
    (comp.lang.perl.misc)
  • CRAP CODE CHRONICLES: Xml
    ... this will be painfull for all the XML experts here on this board. ... sub original_content ... # call new_parse handler ... # call start tag handler with $2 ...
    (comp.lang.perl.misc)
  • RXParse 1.2
    ... this will not be the focus for RXParse. ... Version 1.4 will contain the XP3 engine code to do inline replacement within the SAX handler. ... sub original_content ... # call start tag handler with $2 ...
    (comp.lang.perl.misc)
  • RxParse 1.1 - source code, XML 1.1, all Perl, SAX parser
    ... sub original_content ... elsif eq 'ignore_errors') { ... # call new_parse handler ... # call start tag handler with $2 ...
    (comp.lang.perl.misc)
  • RXParse module (by robic0), Version 0.1000
    ... sub original_content { ... then call content handler with $content ... # call start tag handler with $2 ... throwX('10', undef, undef, undef, undef); ...
    (comp.lang.perl.misc)