Share via


AnalysisWarningBase.BackgroundException Property

The Exception that is thrown if an exception occurs in during background analysis of ink.

Namespace:  System.Windows.Ink.AnalysisCore
Assembly:  IACore (in IACore.dll)

Syntax

'Declaration
Public ReadOnly Property BackgroundException As Exception
'Usage
Dim instance As AnalysisWarningBase 
Dim value As Exception 

value = instance.BackgroundException
public Exception BackgroundException { get; }
public:
property Exception^ BackgroundException {
    Exception^ get ();
}
public function get BackgroundException () : Exception

Property Value

Type: System.Exception
The Exception that was thrown during background analysis.

Remarks

If an Exception occurs after a call to InkAnalyzerBase.BackgroundAnalyze, then the exception cannot be thrown because it is occurring in a different thread and there is no way to catch it. Instead, in the ResultsUpdated event handler, the Status property of the ResultsUpdatedEventArgs object will have an AnalysisWarningBase object of type BackgroundException in its Warnings collection. The BackgroundException property of this AnalysisWarningBase object will contain the Exception that was thrown during background analysis. In general, you will want to rethrow this Exception so that it can be caught elsewhere in your application.

Examples

The following example shows an AnalysisWarningBase, warning, which is checked to see if it is associated with any hints. If the AnalysisWarningBase is of type BackgroundException , then you should attempt to save as much document state as possible and then rethrow the exception so that it can be caught by an exception handler. Even if no exception handler is in place, then a program error debugger, such as Dr. Watson, can be invoked. The InkAnalyzerBase will need to be reinitialized after catching the exception.

If Not (warning.AnalysisHint Is Nothing) Then 

    Dim hint As ContextNodeBase = warning.AnalysisHint
    message = message & Environment.NewLine & "Hint information: "
    message = message & "AllowPartialDictionaryTerms" 
    If hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.AllowPartialDictionaryTerms) Then
        message = message & " = " & _
            hint.GetPropertyData( _
                PropertyGuidsForAnalysisHintsBase.AllowPartialDictionaryTerms).ToString()
    Else
        message = message & " = False " 
    End If
    message = message & "CoerceToFactoid" 
    If hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.CoerceToFactoid) Then
        message = message & " = " & _
            hint.GetPropertyData( _
                PropertyGuidsForAnalysisHintsBase.CoerceToFactoid).ToString()
    Else
        message = message & " = False " 
    End If 
    If hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.Factoid) Then
        message = message & "Factoid = " & _
            warning.AnalysisHint.GetPropertyData(PropertyGuidsForAnalysisHintsBase.Factoid) & " " 
    End If 
    If hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.Guide) Then 
        Dim theInkRecognizerGuideBase As InkRecognizerGuideBase = _
            CType(hint.GetPropertyData(PropertyGuidsForAnalysisHintsBase.Guide), _
                  InkRecognizerGuideBase)

        message += "Guide Drawn Box = {" & theInkRecognizerGuideBase.DrawnBoxLeft.ToString() _
                                      & ", " & theInkRecognizerGuideBase.DrawnBoxTop.ToString() _
                                      & ", " & theInkRecognizerGuideBase.DrawnBoxRight.ToString() _
                                      & ", " & theInkRecognizerGuideBase.DrawnBoxBottom.ToString() _
                                      & ")"

        message &= "Guide Writing Box = {" & theInkRecognizerGuideBase.WritingBoxLeft.ToString() _
                                        & ", " & theInkRecognizerGuideBase.WritingBoxTop.ToString() _
                                        & ", " & theInkRecognizerGuideBase.WritingBoxRight.ToString() _
                                        & ", " & theInkRecognizerGuideBase.WritingBoxBottom.ToString() _
                                        & ")"

        message = message & String.Format("Guide = ({0}, {1})", _
             theInkRecognizerGuideBase.Columns, theInkRecognizerGuideBase.Rows)

    End If 

    If hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.Name) Then
        message = message & "Name = " & _
            CType(warning.AnalysisHint.GetPropertyData(PropertyGuidsForAnalysisHintsBase.Name), String) _
            & " " 
    End If 

    If Not hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.PrefixText) Then
        message = message & "PrefixText = " & _
            CType(warning.AnalysisHint.GetPropertyData(PropertyGuidsForAnalysisHintsBase.PrefixText), String) _
            & " " 
    End If 

    If Not hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.SuffixText) Then
        message = message & "SuffixText = " & _
            CType(warning.AnalysisHint.GetPropertyData(PropertyGuidsForAnalysisHintsBase.SuffixText), String) _
            & " " 
    End If

    message = message & "WordMode" 
    If hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.WordMode) Then
        message = message & " = " & _
            CType(hint.GetPropertyData(PropertyGuidsForAnalysisHintsBase.WordMode), String)
    Else
        message = message & " = False" 
    End If 
End If
if (warning.AnalysisHint != null)
{
    ContextNodeBase  hint = warning.AnalysisHint;
    message += Environment.NewLine + "Hint information: ";
    message += "AllowPartialDictionaryTerms";

    if (hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.AllowPartialDictionaryTerms))
        message += " = " +
            ((bool)hint.GetPropertyData(
                PropertyGuidsForAnalysisHintsBase.AllowPartialDictionaryTerms)).ToString();
    else
        message += " = false ";

    message += "CoerceToFactoid";
    if (hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.CoerceToFactoid))
        message += " = " +
            ((bool)hint.GetPropertyData(
                PropertyGuidsForAnalysisHintsBase.CoerceToFactoid)).ToString();
    else
        message += " = false ";

    if (hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.Factoid))
        message += "Factoid = " + 
            (string) warning.AnalysisHint.GetPropertyData(
            PropertyGuidsForAnalysisHintsBase.Factoid) + " ";

    if (hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.Guide))
    {
        InkRecognizerGuideBase theInkRecognizerGuideBase = 
            (InkRecognizerGuideBase) hint.GetPropertyData(
            PropertyGuidsForAnalysisHintsBase.Guide);

        message += "Guide Drawn Box = {" + theInkRecognizerGuideBase.DrawnBoxLeft.ToString()
                                  + ", " + theInkRecognizerGuideBase.DrawnBoxTop.ToString()
                                  + ", " + theInkRecognizerGuideBase.DrawnBoxRight.ToString()
                                  + ", " + theInkRecognizerGuideBase.DrawnBoxBottom.ToString() 
                                  + ")";

        message += "Guide Writing Box = {" + theInkRecognizerGuideBase.WritingBoxLeft.ToString()
                                    + ", " + theInkRecognizerGuideBase.WritingBoxTop.ToString()
                                    + ", " + theInkRecognizerGuideBase.WritingBoxRight.ToString()
                                    + ", " + theInkRecognizerGuideBase.WritingBoxBottom.ToString()
                                    + ")";  

    }
    if (hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.Name))
        message += "Name = " +
            (string) warning.AnalysisHint.GetPropertyData(
                PropertyGuidsForAnalysisHintsBase.Name);

    if (hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.PrefixText))
        message += "PrefixText = " + 
            (string) warning.AnalysisHint.GetPropertyData(
                PropertyGuidsForAnalysisHintsBase.PrefixText) + " ";
    if (hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.SuffixText))
        message += "SuffixText = " + 
            (string) warning.AnalysisHint.GetPropertyData(
                PropertyGuidsForAnalysisHintsBase.SuffixText) + " ";
    message += "WordMode";

    if (hint.ContainsPropertyData(PropertyGuidsForAnalysisHintsBase.WordMode))
        message += " = " +
            ((bool) hint.GetPropertyData(
                PropertyGuidsForAnalysisHintsBase.WordMode)).ToString();
    else
        message += " = false";
}

Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Version Information

.NET Framework

Supported in: 3.0

See Also

Reference

AnalysisWarningBase Class

AnalysisWarningBase Members

System.Windows.Ink.AnalysisCore Namespace

InkAnalyzerBase.BackgroundAnalyze