//****************************************************************************************************** // ISynchronizedOperation.cs - Gbtc // // Copyright © 2014, Grid Protection Alliance. All Rights Reserved. // // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See // the NOTICE file distributed with this work for additional information regarding copyright ownership. // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may // not use this file except in compliance with the License. You may obtain a copy of the License at: // // http://www.opensource.org/licenses/MIT // // Unless agreed to in writing, the subject software distributed under the License is distributed on an // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the // License for the specific language governing permissions and limitations. // // Code Modification History: // ---------------------------------------------------------------------------------------------------- // 03/21/2014 - Stephen C. Wills // Generated original version of source code. // //****************************************************************************************************** namespace GSF.Threading { /// /// Represents the available types of synchronized operations. /// public enum SynchronizedOperationType { /// /// /// Short, /// /// /// Long, /// /// with IsBackground set to true /// LongBackground, /// /// /// Mixed, /// /// with IsBackground set to false /// DedicatedForeground, /// /// with IsBackground set to true /// DedicatedBackground, } /// /// Represents an operation that cannot run while it is already in progress. /// public interface ISynchronizedOperation { /// /// Gets a value to indicate whether the synchronized /// operation is currently executing its action. /// bool IsRunning { get; } /// /// Gets a value to indiate whether the synchronized operation /// has an additional operation that is pending execution after /// the currently running action has completed. /// bool IsPending { get; } /// /// Executes the action on this thread or marks the /// operation as pending if the operation is already running. /// /// /// When the operation is marked as pending, it will run again after /// the operation that is currently running has completed. This is useful /// if an update has invalidated the operation that is currently running /// and will therefore need to be run again. /// /// This method does not guarantee that control will be returned to the /// thread that called it. If other threads continuously mark the operation as /// pending, this thread will continue to run the operation indefinitely. /// void Run(); /// /// Attempts to execute the action on this thread. /// Does nothing if the operation is already running. /// /// /// This method does not guarantee that control will be returned to the thread /// that called it. If other threads continuously mark the operation as pending, /// this thread will continue to run the operation indefinitely. /// void TryRun(); /// /// Executes the action on this thread or marks the /// operation as pending if the operation is already running. /// /// /// When the operation is marked as pending, it will run again after the /// operation that is currently running has completed. This is useful if /// an update has invalidated the operation that is currently running and /// will therefore need to be run again. /// void RunOnce(); /// /// Executes the action on another thread or marks the /// operation as pending if the operation is already running. /// /// /// When the operation is marked as pending, it will run again after the /// operation that is currently running has completed. This is useful if /// an update has invalidated the operation that is currently running and /// will therefore need to be run again. /// void RunOnceAsync(); /// /// Attempts to execute the action on this thread. /// Does nothing if the operation is already running. /// void TryRunOnce(); /// /// Attempts to execute the action on another thread. /// Does nothing if the operation is already running. /// void TryRunOnceAsync(); } }