Пример #1
0
        /// <summary>
        /// Creates a task to generate a compiled saga factory method that is faster than the
        /// regular Activator, but doing this asynchronously ensures we don't slow down startup
        /// </summary>
        /// <returns></returns>
        async Task GenerateFactoryMethodAsynchronously()
        {
            await Task.Yield();

            try
            {
                var factory = new ConstructorSagaInstanceFactory <TSaga>();

                Interlocked.Exchange(ref _factoryMethod, factory.FactoryMethod);
            }
            catch (Exception ex)
            {
                LogContext.Error?.Log(ex, "Generate constructor instance factory faulted: {SagaType}", TypeMetadataCache <TSaga> .ShortName);
            }
        }
Пример #2
0
        /// <summary>
        /// Creates a task to generate a compiled saga factory method that is faster than the
        /// regular Activator, but doing this asynchronously ensures we don't slow down startup
        /// </summary>
        /// <returns></returns>
        async Task GenerateFactoryMethodAsynchronously()
        {
            await Task.Yield();

            try
            {
                var factory = new ConstructorSagaInstanceFactory <TSaga>();

                Interlocked.Exchange(ref _factoryMethod, factory.FactoryMethod);
            }
            catch (Exception ex)
            {
                if (_log.IsErrorEnabled)
                {
                    _log.Error($"Failed to generate constructor instance factory for {TypeMetadataCache<TSaga>.ShortName}", ex);
                }
            }
        }