internal override void ConnectAsync()
        {
            List <WSManNativeApi.WSManOption> wsManOptionList = new List <WSManNativeApi.WSManOption>((IEnumerable <WSManNativeApi.WSManOption>)WSManClientSessionTransportManager.wsManApiStaticData.CommonOptionSet);

            if ((object)WSManClientSessionTransportManager.protocolVersionRedirect != null)
            {
                string str = (string)WSManClientSessionTransportManager.protocolVersionRedirect.DynamicInvoke();
                wsManOptionList.Clear();
                wsManOptionList.Add(new WSManNativeApi.WSManOption()
                {
                    name       = "protocolversion",
                    value      = str,
                    mustComply = true
                });
            }
            WSManNativeApi.WSManShellStartupInfo startupInfo = new WSManNativeApi.WSManShellStartupInfo(WSManClientSessionTransportManager.wsManApiStaticData.InputStreamSet, WSManClientSessionTransportManager.wsManApiStaticData.OutputStreamSet, 0L > this.idleTimeout || this.idleTimeout >= (long)uint.MaxValue ? uint.MaxValue : (uint)this.idleTimeout);
            if (this.openContent == null)
            {
                byte[] inArray = this.dataToBeSent.ReadOrRegisterCallback((PrioritySendDataCollection.OnDataAvailableCallback)null, out DataPriorityType _);
                bool   flag    = true;
                if ((object)WSManClientSessionTransportManager.sessionSendRedirect != null)
                {
                    object[] objArray = new object[2]
                    {
                        null,
                        (object)inArray
                    };
                    flag    = (bool)WSManClientSessionTransportManager.sessionSendRedirect.DynamicInvoke(objArray);
                    inArray = (byte[])objArray[0];
                }
                if (!flag)
                {
                    return;
                }
                if (inArray != null)
                {
                    this.openContent = new WSManNativeApi.WSManData(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "<{0} xmlns=\"{1}\">{2}</{0}>", (object)"creationXml", (object)"http://schemas.microsoft.com/powershell", (object)Convert.ToBase64String(inArray, Base64FormattingOptions.None)));
                }
            }
            this.sessionContextID = WSManClientSessionTransportManager.GetNextSessionTMHandleId();
            WSManClientSessionTransportManager.AddSessionTransportManager(this.sessionContextID, this);
            BaseTransportManager.ETWTracer.AnalyticChannel.WriteInformation(PSEventId.WSManCreateShell, PSOpcode.Connect, PSTask.CreateRunspace, (object)this.RunspacePoolInstanceId);
            this.createSessionCompleted         = new WSManNativeApi.WSManShellAsync(new IntPtr(this.sessionContextID), WSManClientSessionTransportManager.sessionCreateCallback);
            this.createSessionCompletedGCHandle = GCHandle.Alloc((object)this.createSessionCompleted);
            try
            {
                lock (this.syncObject)
                {
                    if (this.isClosed)
                    {
                        return;
                    }
                    if (this.noMachineProfile)
                    {
                        wsManOptionList.Add(new WSManNativeApi.WSManOption()
                        {
                            name       = "WINRS_NOPROFILE",
                            mustComply = true,
                            value      = "1"
                        });
                    }
                    using (WSManNativeApi.WSManOptionSet optionSet = new WSManNativeApi.WSManOptionSet(wsManOptionList.ToArray()))
                        WSManNativeApi.WSManCreateShellEx(this.wsManSessionHandle, this.noCompression ? 1 : 0, this.resourceUri, startupInfo, optionSet, this.openContent, (IntPtr)this.createSessionCompleted, ref this.wsManShellOperationHandle);
                }
                if (!(this.wsManShellOperationHandle == IntPtr.Zero))
                {
                    return;
                }
                this.RaiseErrorHandler(WSManTransportManagerUtils.ConstructTransportErrorEventArgs(WSManClientSessionTransportManager.wsManApiStaticData.WSManAPIHandle, IntPtr.Zero, new WSManNativeApi.WSManError(), TransportMethodEnum.CreateShellEx, PSRemotingErrorId.ConnectExFailed));
            }
            finally
            {
                startupInfo.Dispose();
            }
        }