示例#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);
        }
        internal void InvokeActivate(FabricRuntime runtime, CodePackageActivationContext activationContext)
        {
            Debug.Assert(this.runtime == null, "Activate has already been called.");
            Debug.Assert(this.activationContext == null, "Activate has already been called.");

            this.runtime           = runtime;
            this.activationContext = activationContext;

            try
            {
                this.Activate(this.runtime, this.activationContext);
            }
            catch (Exception e)
            {
                AppTrace.TraceSource.WriteExceptionAsError(
                    "FabricWorkerEntryPoint.Activate",
                    e,
                    "Failed to activate entrypoint {0} from assembly {1}",
                    this.GetType(),
                    this.assemblyDescription);
                throw;
            }
        }
示例#3
0
 private FabricRuntime InitializeFabricRuntimeEndWrapper(FabricRuntime runtime, NativeCommon.IFabricAsyncOperationContext context)
 {
     runtime.nativeRuntime = NativeRuntime.FabricEndCreateRuntime(context);
     return(runtime);
 }
示例#4
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));
 }
示例#5
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));
 }
示例#6
0
 /// <summary>
 /// <para>Creates the <see cref="System.Fabric.FabricRuntime" /> object.</para>
 /// </summary>
 /// <returns>
 /// <para>A newly created <see cref="System.Fabric.FabricRuntime" /> object.</para>
 /// </returns>
 public static FabricRuntime Create()
 {
     return(FabricRuntime.Create(null));
 }
 /// <summary>
 /// <para> Reserved for future use.</para>
 /// </summary>
 /// <param name="runtime">
 /// <para>Reserved for future use.</para>
 /// </param>
 /// <param name="activationContext">
 /// <para>Reserved for future use.</para>
 /// </param>
 protected abstract void Activate(FabricRuntime runtime, CodePackageActivationContext activationContext);