Re: Dealing with AdvancedSearch and AdvancedSearchComplete
- From: "blueinc" <blueinc@xxxxxxxxxxxxx>
- Date: Sat, 24 Sep 2005 03:56:01 -0700
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
>
>
.
- Follow-Ups:
- Re: Dealing with AdvancedSearch and AdvancedSearchComplete
- From: Ken Slovak - [MVP - Outlook]
- Re: Dealing with AdvancedSearch and AdvancedSearchComplete
- References:
- Re: Dealing with AdvancedSearch and AdvancedSearchComplete
- From: Ken Slovak - [MVP - Outlook]
- Re: Dealing with AdvancedSearch and AdvancedSearchComplete
- From: blueinc
- Re: Dealing with AdvancedSearch and AdvancedSearchComplete
- From: Ken Slovak - [MVP - Outlook]
- Re: Dealing with AdvancedSearch and AdvancedSearchComplete
- Prev by Date: Re: Setting the homepage of a folder
- Next by Date: Re: Setting the homepage of a folder
- Previous by thread: Re: Dealing with AdvancedSearch and AdvancedSearchComplete
- Next by thread: Re: Dealing with AdvancedSearch and AdvancedSearchComplete
- Index(es):
Relevant Pages
|