예제 #1
0
        /// <summary>
        /// <para>Creates the <see cref="System.Fabric.FabricRuntime" /> object with a specified callback function which will be executed if the
        /// underlying runtime terminates or exits for any reason.</para>
        /// </summary>
        /// <param name="fabricExitCallback">
        /// <para>The Action to be executed when the runtime exits or terminates.</para>
        /// </param>
        /// <returns>
        /// <para>A newly created <see cref="System.Fabric.FabricRuntime" />object.</para>
        /// </returns>
        public static FabricRuntime Create(Action fabricExitCallback)
        {
            //AppTrace.TraceSource.WriteInfo("FabricRuntime.Create");

            FabricRuntime        fabricRuntime = null;
            Task <FabricRuntime> task          = null;

            try
            {
                task = FabricRuntime.CreateAsyncHelper(fabricExitCallback, FabricRuntime.DefaultFabricRuntimeCreationTimeout, CancellationToken.None);
                task.Wait();
                fabricRuntime = task.Result;
            }
            catch (AggregateException ex)
            {
                throw ex.InnerException;
            }

            return(fabricRuntime);
        }
예제 #2
0
 /// <summary>
 /// <para>Creates the <see cref="System.Fabric.FabricRuntime" /> object asynchronously with the specified callback function which will be executed
 /// if the underlying runtime terminates or exits for any reason, <paramref name="timeout" />, and <paramref name="cancellationToken" />. </para>
 /// </summary>
 /// <param name="fabricExitCallback">
 /// <para>The Action to be executed when the runtime exits or terminates.</para>
 /// </param>
 /// <param name="timeout">
 /// <para>The maximum amount of time Service Fabric will allow this operation to continue before returning a TimeoutException.</para>
 /// </param>
 /// <param name="cancellationToken">
 /// <para>The <see cref="System.Threading.CancellationToken" /> that the operation is observing.  It can be used to send a notification that the
 /// operation should be canceled.  Note that cancellation is advisory and that the operation may still be completed even if it is canceled.</para>
 /// </param>
 /// <returns>
 /// <para>The task representing the asynchronous operation.</para>
 /// </returns>
 public static Task <FabricRuntime> CreateAsync(Action fabricExitCallback, TimeSpan timeout, CancellationToken cancellationToken)
 {
     //AppTrace.TraceSource.WriteInfo("FabricRuntime.CreateAsync");
     return(FabricRuntime.CreateAsyncHelper(fabricExitCallback, timeout, cancellationToken));
 }
예제 #3
0
 /// <summary>
 /// <para>Creates the <see cref="System.Fabric.FabricRuntime" /> object asynchronously with the specified <paramref name="timeout" /> and
 /// <paramref name="cancellationToken" />.</para>
 /// </summary>
 /// <param name="timeout">
 /// <para>The maximum amount of time Service Fabric will allow this operation to continue before returning a TimeoutException.</para>
 /// </param>
 /// <param name="cancellationToken">
 /// <para>The <see cref="System.Threading.CancellationToken" /> that the operation is observing.  It can be used to send a notification that
 /// the operation should be canceled.  Note that cancellation is advisory and that the operation may still be completed even if it is canceled.</para>
 /// </param>
 /// <returns>
 /// <para>The task representing the asynchronous operation.</para>
 /// </returns>
 public static Task <FabricRuntime> CreateAsync(TimeSpan timeout, CancellationToken cancellationToken)
 {
     return(FabricRuntime.CreateAsyncHelper(null, timeout, cancellationToken));
 }