当前位置: 首页>>代码示例>>C#>>正文


C# ConnectionState类代码示例

本文整理汇总了C#中ConnectionState的典型用法代码示例。如果您正苦于以下问题:C# ConnectionState类的具体用法?C# ConnectionState怎么用?C# ConnectionState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ConnectionState类属于命名空间,在下文中一共展示了ConnectionState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ExcuteSQLBulkCopy

        public void ExcuteSQLBulkCopy(DataTable Datatable, string TableName, ConnectionState connectionstate, ref bool executionSucceeded)
        {
            try
            {
                if (objConnection.State == System.Data.ConnectionState.Closed)
                {
                    objConnection.Open();
                }

                SqlBulkCopy.BatchSize = Datatable.Rows.Count;
                SqlBulkCopy.BulkCopyTimeout = 0;
                SqlBulkCopy.DestinationTableName = TableName;
                SqlBulkCopy.WriteToServer(Datatable);
                SqlBulkCopy.Close();
                executionSucceeded = true;
            }
            catch (Exception ex)
            {
                executionSucceeded = false;
                HandleExceptions(ex);
            }
            finally
            {
                //SqlBulkCopy.ColumnMappings.Clear();

                if (connectionstate == ConnectionState.CloseOnExit)
                {
                    if (objConnection.State == System.Data.ConnectionState.Open)
                    {
                        objConnection.Close();
                    }
                }
            }
        }
开发者ID:shekar348,项目名称:1PointOne,代码行数:34,代码来源:DatabaseHelperExtension.cs

示例2: OnStateChanged

 private void OnStateChanged(ConnectionState newState)
 {
     if (_stateChanged != null)
     {
         _stateChanged(this, newState);
     }
 }
开发者ID:GeorgeManiya,项目名称:EpamTraining,代码行数:7,代码来源:Port.cs

示例3: SerialConnection

 private SerialConnection()
 {
     Devices = new ObservableCollection<DeviceInformation>();
     State = ConnectionState.Disconnected;
     Debugger = Debugger.Instance;
     LookForBluetoothDevices();
 }
开发者ID:AliceTheCat,项目名称:LightTable,代码行数:7,代码来源:SerialConnection.cs

示例4: Open

        public override void Open()
        {
            if (State == ConnectionState.Open)
                throw new Exception("Connection is already open");

            _state = ConnectionState.Open;
        }
开发者ID:erikojebo,项目名称:WeenyMapper,代码行数:7,代码来源:TestDbConnection.cs

示例5: Close

        public override void Close()
        {
            if (State == ConnectionState.Closed)
                throw new Exception("Connection is already closed");

            _state = ConnectionState.Closed;
        }
开发者ID:erikojebo,项目名称:WeenyMapper,代码行数:7,代码来源:TestDbConnection.cs

示例6: connectionChanged

 private void connectionChanged(ConnectionInformation information, ConnectionState state)
 {
     if (state == ConnectionState.CLOSED)
     {
         CloseConnection(information);
     }
 }
开发者ID:BjkGkh,项目名称:Boon,代码行数:7,代码来源:ConnectionHandling.cs

示例7: OnStateChanged

 public void OnStateChanged(ConnectionState connectionState)
 {
     if (callback != null)
     {
         callback(connectionState);
     }
 }
开发者ID:JamesEarle,项目名称:Microsoft-Band-SDK-Bindings,代码行数:7,代码来源:BandClientExtensions.cs

示例8: Open

        public bool Open()
        {
            if (m_State == ConnectionState.Disconnected)
            {
                int numUnits = m_PM3.DiscoverUnits();
                if (numUnits > 0)
                {
                    try
                    {
                        m_Port = 0;
                        m_State = ConnectionState.Connected;
                    }
                    catch (PM3Exception e)
                    {
                        Debug.WriteLine(string.Format("[Connection.Open] {0}", e.Message));
                    }
                }
            }
            else
            {
                Debug.WriteLine("[Connection.Open] Connection already open");
            }

            return IsOpen;
        }
开发者ID:spinglass,项目名称:Performant,代码行数:25,代码来源:Connection.cs

示例9: AcceptCallback

        public void AcceptCallback(IAsyncResult result)
        {
            // Get the socket that handles the client request
            // listener represents the connection 'server' (that waits for clients to connect) and not the
            // individual client connections
            Socket listener = (Socket)result.AsyncState;
            Socket handler = listener.EndAccept(result);

            // Tell the main client thread we got one client so that it can keep waiting for others :)
            gAllDone.Set();

            // From now on this is a separate thread :) cool!
            // Lets keep the state of this thing shall we?
            ConnectionState state = new ConnectionState();
            state.mSocket = handler;

            // TODO: Implement version control here
            // Valid connections start with a 'YELLOW' to which we respond 'SUP'
            byte[] yellowShakeBuffer = new byte[16];
            int read = handler.Receive(yellowShakeBuffer);
            string yellowString = ServerApi.CONNECTION_ENCODING.GetString(yellowShakeBuffer, 0, read);
            if (yellowString.Equals("YELLOW"))
            {
                // Answer and start waiting for data baby!
                handler.Send(ServerApi.CONNECTION_ENCODING.GetBytes("SUP"));
                handler.BeginReceive(state.mBuffer, 0, ConnectionState.BufferSize, SocketFlags.Peek,
                                    new AsyncCallback(ReadCallback), state);
            }
            else
            {
                // Ooops, not a valid client!
                handler.Close();
            }
        }
开发者ID:DiogoNeves,项目名称:DataSmasher,代码行数:34,代码来源:NetworkJobListener.cs

示例10: SendCSAFECommand

 public bool SendCSAFECommand(uint[] cmdData, ushort cmdDataCount, uint[] rspData, ref ushort rspDataCount)
 {
     if (IsOpen)
     {
         try
         {
             m_PM3.SendCSAFECommand(m_Port, cmdData, cmdDataCount, rspData, ref rspDataCount);
             return true;
         }
         catch (WriteFailedException e)
         {
             m_State = ConnectionState.SendError;
             Debug.WriteLine(string.Format("[Connection.SendCSAFECommand] {0}", e.Message));
         }
         catch (ReadTimeoutException e)
         {
             m_State = ConnectionState.SendError;
             Debug.WriteLine(string.Format("[Connection.SendCSAFECommand] {0}", e.Message));
         }
         catch (DeviceClosedException e)
         {
             m_State = ConnectionState.Disconnected;
             Debug.WriteLine(string.Format("[Connection.SendCSAFECommand] {0}", e.Message));
         }
     }
     return false;
 }
开发者ID:b0urb4k1,项目名称:Concept2-Rower,代码行数:27,代码来源:Connection.cs

示例11: Open

        public override void Open()
        {
            m_StorageAccount = CloudStorageAccount.Parse(m_ConnectionString);
            m_State = ConnectionState.Open;

            // TODO (Matt Magurany 8/14/2012): Consider creating an HTTP request for batching here
        }
开发者ID:heymagurany,项目名称:TableStorageDataProvider,代码行数:7,代码来源:TableStorageConnection.cs

示例12: Handle

 /// <summary>Executes behavior.</summary>
 /// <param name="state">Connection state.</param>
 public void Handle(ConnectionState state)
 {
     if (state == ConnectionState.Connected)
         _viewModel.IsBusy = false;
     else
         ErrorManager.Error(state.ToString());
 }
开发者ID:brainster-one,项目名称:uberball,代码行数:9,代码来源:ConnectionStateChangedBehavior.cs

示例13: OnMessageReceived

        private async void OnMessageReceived(object sender, MessageReceivedEventArgs args)
        {
            if (OnData == null) return;

            var exceptionOccured = false;
            try
            {
                var text = args.Message;
                OnData(sender, new DataReceivedEventArgs { TextData = text });
            }
            catch (Exception)
            {
                exceptionOccured = true;
            }
            // cannot await in catch
            if (exceptionOccured)
            {
                _connectionState = ConnectionState.Failed;
                try
                {
                    await Reconnect();
                }
                catch (Exception e)
                {
                    Error(e);
                }
            }
        }
开发者ID:luiseduardohdbackup,项目名称:Pusher.NET,代码行数:28,代码来源:WebSocketConnection.cs

示例14: BeginConnect

        protected async Task BeginConnect(CancellationToken parentCancelToken)
        {
            try
            {
                using (await _lock.LockAsync().ConfigureAwait(false))
                {
                    _parentCancelToken = parentCancelToken;

                    await _taskManager.Stop().ConfigureAwait(false);
                    _taskManager.ClearException();
                    State = ConnectionState.Connecting;

                    _cancelSource = new CancellationTokenSource();
                    CancelToken = CancellationTokenSource.CreateLinkedTokenSource(_cancelSource.Token, parentCancelToken).Token;
                    _lastHeartbeat = DateTime.UtcNow;

                    await _engine.Connect(Host, CancelToken).ConfigureAwait(false);
                    await Run().ConfigureAwait(false);
                }
            }
            catch (Exception ex)
            {
                //TODO: Should this be inside the lock?
                await _taskManager.SignalError(ex).ConfigureAwait(false);
                throw;
            }
        }
开发者ID:Carbonitex,项目名称:Discord.Net,代码行数:27,代码来源:WebSocket.cs

示例15: CiiClient

        public CiiClient()
        {
            logger = Logger.Instance;
            StatusCallbacks = new Dictionary<uint, ReceiveStatusHandler>();
            statusCallbacksLock = new object();

            loginAcceptEvent = new AutoResetEvent(false);
            messagesInFlight = new CiiMessagesInFlight();
            connectionState = ConnectionState.NotConnected;

            //
            //  Prebuild the Communications arrays
            //
            MessageTypeGet = BitConverter.GetBytes((uint)CiiMessageType.MtGetCommand);
            MessageTypeAction = BitConverter.GetBytes((uint)CiiMessageType.MtActionCommand);
            BytesLogin = BitConverter.GetBytes((uint)CiiMessageType.MtLogin);

            asyncErrorEvent = new AutoResetEvent(false);
            asyncErrors = new Queue<string>();
            asyncErrorsLock = new object();
            asyncErrorThread = new Thread(AsyncErrorThread);
            asyncErrorThread.IsBackground = true;
            asyncErrorThread.Priority = ThreadPriority.AboveNormal;
            asyncErrorThread.Name = "AsyncErrorThread";
            asyncErrorThread.Start();
        }
开发者ID:michaelbeckertainstruments,项目名称:common-instrument-interface-client-csharp,代码行数:26,代码来源:CiiClient.cs


注:本文中的ConnectionState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。