• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ConnectionState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: AudioClient

        public AudioClient(DiscordClient client, Server server, int id)
		{
            Id = id;
            _config = client.Config;
            Service = client.Services.Get<AudioService>();
            Config = Service.Config;
            Serializer = client.Serializer;
            _gatewayState = (int)ConnectionState.Disconnected;

            //Logging
            Logger = client.Log.CreateLogger($"AudioClient #{id}");

            //Async
            _taskManager = new TaskManager(Cleanup, false);
            _connectionLock = new AsyncLock();
            CancelToken = new CancellationToken(true);

            //Networking
            if (Config.EnableMultiserver)
            {
                ClientAPI = new JsonRestClient(_config, DiscordConfig.ClientAPIUrl, client.Log.CreateLogger($"ClientAPI #{id}"));
                GatewaySocket = new GatewaySocket(_config, client.Serializer, client.Log.CreateLogger($"Gateway #{id}"));
                GatewaySocket.Connected += (s, e) =>
                {
                    if (_gatewayState == ConnectionState.Connecting)
                        EndGatewayConnect();
                };
            }
            else
                GatewaySocket = client.GatewaySocket;
            GatewaySocket.ReceivedDispatch += (s, e) => OnReceivedEvent(e);
            VoiceSocket = new VoiceSocket(_config, Config, client.Serializer, client.Log.CreateLogger($"Voice #{id}"));
            VoiceSocket.Server = server;
            OutputStream = new OutStream(this);
        }
开发者ID:asdfgasdfsafgsdfa,项目名称:Discord.Net,代码行数:35,代码来源:AudioClient.cs


示例17: Uri

        private static Uri uri = new Uri("net.tcp://localhost:57000"); // объектное представление универсального кода ресурсов (URI)

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Инициализирует новый экземпляр класса
        /// </summary>
        private DevManClient()
        {
            devContext = new DevManClientContext();
            devContext.onUpdate += new EventHandler(devContext_onUpdate);

            connectionState = ConnectionState.Default;
        }
开发者ID:slawer,项目名称:asy,代码行数:16,代码来源:DevManClient.cs


示例18: CqlConnection

 public CqlConnection()
 {
     _ConnectionState = ConnectionState.Closed;
     _Config = new CqlConnectionConfiguration();
     _CurrentKeyspace = "";
     _ActualConnection = null;
 }
开发者ID:razzmatazz,项目名称:cassandra-sharp-client,代码行数:7,代码来源:CqlConnection.cs


示例19: ConnectTo

        public void ConnectTo(string hostName, ushort port = 80)
        {
            // Disconnect from any existing connection
            Disconnect();

            // Get the IP address from the host name string
            IPAddress[] addresses = Dns.GetHostAddresses(hostName);
            if( addresses.Length > 0 )
            {
                try
                {
                    mSocket.Connect(addresses[0], port);
                    mState = ConnectionState.Connecting;
                }
                catch( SocketException ex )
                {
                    if (ex.ErrorCode == 10035)
                    {
                        // Would Block
                        mState = ConnectionState.Connecting;
                    }
                    else
                        Console.WriteLine(ex.Message);
                }
            }
        }
开发者ID:GarageGames,项目名称:Bitcoin,代码行数:26,代码来源:Connection.cs


示例20: connectionChanged

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ConnectionStatus类代码示例发布时间:2022-05-24
下一篇:
C# ConnectionSettings类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap