WinForms

Code Examples Upgrade Guide User Guide Demos Support Forums Download
  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class OperationFeedback

    Show / Hide Table of Contents

    Class OperationFeedback

    Use this class when you want to provide feedback during time-consuming operations or if you want the user to be able to abort an operation.

    Inheritance
    System.Object
    OperationFeedback
    Implements
    System.IDisposable
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: Syncfusion.ComponentModel
    Assembly: Syncfusion.Shared.Base.dll
    Syntax
    public sealed class OperationFeedback : IDisposable
    Remarks

    You need to implement IOperationFeedbackProvider in your class.

    // interface IOperationFeedbackProvider
    public event OperationFeedbackEventHandler OperationFeedback;
    Stack feedbackStack = new Stack();
    void IOperationFeedbackProvider.RaiseOperationFeedbackEvent(OperationFeedbackEventArgs e)
    {
        if (OperationFeedback != null)
                OperationFeedback(this, e);
    }
    Stack IOperationFeedbackProvider.FeedbackStack
    {
        get { return feedbackStack; }
    }

    When you implement an operation that you want to be cancellable or where you want to show feedback (e.g. display percentage in status bar) you do this by creating an OperationFeedback object inside a using statement.

    Example:

    using (OperationFeedback op = new OperationFeedback(this))
    {
        op.Name = "Cell";
        op.Description = "Command Description";
        op.AllowCancel = true;
        op.AllowNestedProgress = true;
        op.AllowNestedFeedback = false;
        while (n++ != 100)
        {
            if (op.ShouldCancel())
                return;
    
            op.PercentComplete = n;
        }
    }

    It is also supported in nest operations in case your method calls other routines that also use OperationFeedback. AllowNestedProgress will disable OperationFeedback and OperationProgress / ShouldCancel in nested routines. AllowNestedFeedback will simply prohibit changing the description. But the object will still fire OperationProgress events.

    A sample for a consumer is the DelayedWaitCursor class. You can assign a DelayedWaitCursor to a grid table. The DelayedWaitCursor object will listen to OperationFeedback events and automatically change the cursor to a wait cursor if operations take more time.

    Constructors

    OperationFeedback(IOperationFeedbackProvider)

    Initializes a new OperationFeedback object and pushes the object onto the providers feedback stack.

    Declaration
    public OperationFeedback(IOperationFeedbackProvider feedback)
    Parameters
    Type Name Description
    IOperationFeedbackProvider feedback

    Component that implements IOperationFeedbackProvider.

    Properties

    AllowCancel

    Indicates whether cancelling the current operation is enabled / disabled.

    Declaration
    public bool AllowCancel { get; set; }
    Property Value
    Type Description
    System.Boolean

    AllowNestedFeedback

    Indicates whether percentage display and description for nested operations are enabled / disabled.

    Declaration
    public bool AllowNestedFeedback { get; set; }
    Property Value
    Type Description
    System.Boolean

    AllowNestedProgress

    Indicates whether nested operations are enabled / disabled.

    Declaration
    public bool AllowNestedProgress { get; set; }
    Property Value
    Type Description
    System.Boolean

    AllowRollback

    Indicates whether rolling back (undoing) the current operation is enabled / disabled.

    Declaration
    public bool AllowRollback { get; set; }
    Property Value
    Type Description
    System.Boolean

    Counter

    Returns the number of counts of calls to Progress.

    Declaration
    public int Counter { get; }
    Property Value
    Type Description
    System.Int32

    Description

    Gets / sets the description of the operation. Use localized string (SR.GetString("...")) if necessary.

    Declaration
    public string Description { get; set; }
    Property Value
    Type Description
    System.String

    IsNested

    Indicate whether this operation is nested inside another operation.

    Declaration
    public bool IsNested { get; }
    Property Value
    Type Description
    System.Boolean

    Name

    Gets / sets the short name of the operation.

    Declaration
    public string Name { get; set; }
    Property Value
    Type Description
    System.String

    PercentComplete

    Gets / sets the progress in percentage for the current operation.

    Declaration
    public int PercentComplete { get; set; }
    Property Value
    Type Description
    System.Int32

    Rollback

    Indicates whether the canceled operation should be rolled back.

    Declaration
    public bool Rollback { get; set; }
    Property Value
    Type Description
    System.Boolean

    RollbackConfirmed

    Returns False.

    Declaration
    public bool RollbackConfirmed { get; }
    Property Value
    Type Description
    System.Boolean

    SeriesCount

    Gets / sets the number of series if you have a series of nested operations.

    Declaration
    public int SeriesCount { get; set; }
    Property Value
    Type Description
    System.Int32
    Remarks

    If you know the number of operations in advance, you should specify this value. This allows OperationFeedback to adjust the percentage display to reflect the percentage in the overall operation. If you have two operations, the first operation will show percentage from 0 to 50 and the second from 51 to 100. In the original program code for these operations, you can keep your original calculations (setting percentage from 0 to 100). OperationFeedback simply divides the percentage by SeriesCount when it fires the Progress event.

    ShouldCallProgress

    Indicates whether calls to Progress or ShouldCancel have any effect.

    Declaration
    public bool ShouldCallProgress { get; }
    Property Value
    Type Description
    System.Boolean

    ShouldCancel

    Indicates whether the user wants to abort the operation. ShouldCancel will call Progress.

    Declaration
    public bool ShouldCancel { get; }
    Property Value
    Type Description
    System.Boolean

    ShouldShowFeedback

    Indicates whether the percent complete and description should be shown or discarded for this operation.

    Declaration
    public bool ShouldShowFeedback { get; }
    Property Value
    Type Description
    System.Boolean

    Ticks

    Returns the number of ticks elapsed since the operation was started.

    Declaration
    public int Ticks { get; }
    Property Value
    Type Description
    System.Int32

    Methods

    Close()

    Call this method to signal the end of the operation. If you do not explicitly call this routine it will be called automatically when you are using the "using" statement in C# and / or when Dispose is called.

    Declaration
    public void Close()

    Progress()

    Call this method inside a loop from your method that implements the operation.

    Declaration
    public void Progress()

    Start()

    Call this method to signal the start of the operation. If you do not explicitly call this routine, it will be called automatically the first time Progress or ShouldCancel is called.

    Declaration
    public void Start()

    Explicit Interface Implementations

    IDisposable.Dispose()

    Closes the current operation. Removes the object from FeedbackStack.

    Declaration
    void IDisposable.Dispose()

    Implements

    System.IDisposable

    See Also

    DelayedWaitCursor
    DelayedStatusDialog
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved