Example #1
0
        /// <summary>
        /// Create a persistent session async
        /// </summary>
        /// <param name="startInfo">The session start info</param>
        /// <param name="binding">indicating the binding</param>
        /// <returns>A persistent session instance</returns>
        public static async Task <DurableSession> CreateSessionAsync(SessionStartInfo startInfo, Binding binding)
        {
            Utility.ThrowIfNull(startInfo, "startInfo");

            if (Utility.IsHpcSessionType(startInfo.GetType()))
            {
                SessionStartInfo sessionStartInfo = startInfo;

                Utility.ThrowIfEmpty(sessionStartInfo.Headnode, "headNode");

                if (!sessionStartInfo.DebugModeEnabled && sessionStartInfo.UseInprocessBroker)
                {
                    throw new ArgumentException(SR.InprocessBroker_NotSupportDurableSession, "UseInprocessBroker");
                }

                return((DurableSession)await new SessionFactory()
                       .CreateSession(
                           startInfo,
                           true,
                           Constant.DefaultCreateSessionTimeout,
                           binding).ConfigureAwait(false));
            }
            else
            {
                throw new ArgumentException(SR.BackendNotSupported, "startInfo");
            }
        }
Example #2
0
        /// <summary>
        /// Asynchronous mode of submitting a job and get a ServiceJobSession object.
        /// </summary>
        /// <param name="startInfo">The session start info for creating the service session</param>
        /// <param name="binding">indicting the binding</param>
        /// <returns>A service job session object, including the endpoint address and the two jobs related to this session</returns>
        public static async Task <V3Session> CreateSessionAsync(SessionStartInfo startInfo, Binding binding)
        {
            Utility.ThrowIfNull(startInfo, "startInfo");

            Utility.ThrowIfEmpty(startInfo.Headnode, "headNode");

            if (Utility.IsHpcSessionType(startInfo.GetType()))
            {
                return((V3Session)await HpcSessionFactory.BuildSessionFactory(startInfo).CreateSession(startInfo, false, Constant.DefaultCreateSessionTimeout, binding).ConfigureAwait(false));
            }
            else
            {
                throw new ArgumentException(SR.BackendNotSupported, "startInfo");
            }
        }