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


C# IAsyncResult.ToString方法代码示例

本文整理汇总了C#中IAsyncResult.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# IAsyncResult.ToString方法的具体用法?C# IAsyncResult.ToString怎么用?C# IAsyncResult.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAsyncResult的用法示例。


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

示例1: CameraMovementCallback

        private void CameraMovementCallback(IAsyncResult ar)
        {
            logger.Info("Camera movement {0}", ar.ToString());

            try
            {
                // Restart receive
                _udpClientForCameraMovement.BeginReceive(new AsyncCallback(CameraMovementCallback), null);
                _actionDetectedCallback();
            }
            catch (Exception excp)
            {
                logger.Error("Exception in MainWindow::CameraMovementCallback2 {0}", excp.Message);
            }
        }
开发者ID:robdobsn,项目名称:RdCamViewSysTray,代码行数:15,代码来源:CatDeterrent.cs

示例2: EndOneWayMethod

 public void EndOneWayMethod(IAsyncResult r)
 {
     Log.Trace("EndOneWayMethod: " + r.ToString());
     myAsyncOneWayDelegate.EndInvoke(r);
 }       
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:5,代码来源:BaseServer.cs

示例3: EndSessionTwoWayMethod

 public string EndSessionTwoWayMethod(IAsyncResult r)
 {
     Log.Trace("EndSessionTwoWayMethod: " + r.ToString());
     return (myAsyncSessionTwoWayDelegate.EndInvoke(r));
 }
开发者ID:spzenk,项目名称:sfdocsamples,代码行数:5,代码来源:BaseServer.cs

示例4: HandleRead

        void HandleRead(IAsyncResult ar)
        {
            lock (comlock)
            {
                int bytes;
                try
                {
                    bytes = Pipe.EndRead(ar);
                    if (bytes == 0)
                    {
                        Debug.Print(ar.ToString());
                        Debug.Print(ar.CompletedSynchronously.ToString());
                        Debug.Print(ar.IsCompleted.ToString());
                        onFailure("No bytes to read, pipe closed");
                        return;
                    }
                }
                catch (Exception e)
                {
                    Debug.Print(string.Format("End Read Failed {0}", e.ToString()));
                    onFailure("End read threw exception " + e.ToString());
                    return;
                }

                try
                {
                    processData(bytes);

                    try {
                        Pipe.BeginRead(buffer, bufferreadpos, buffersize - bufferreadpos, HandleRead, this);
                    }
                    catch {
                        onFailure("Pipe broken");
                        return;
                    }
                }
                catch (EndOfStreamException)
                {
                    if (bufferreadpos == buffersize)
                    {
                        buffersize = buffersize * 2;
                        byte[] newbuffer = new byte[buffersize];
                        buffer.CopyTo(newbuffer, 0);
                        buffer = newbuffer;
                    }
                    try
                    {
                        Debug.Print("new read " + bufferreadpos.ToString() + " " + (buffersize - bufferreadpos).ToString());
                        if (!Pipe.CanRead)
                        {
                            Debug.Print("For some reason I can't read from this pipe.  Ideas?");
                        }
                        if (!Pipe.IsConnected) {
                            onFailure("Pipe has gone away");
                            return;
                        }
                        try {
                            Pipe.BeginRead(buffer, bufferreadpos, buffersize - bufferreadpos, HandleRead, this);
                        }
                        catch {
                            onFailure("Pipe broken");
                            return;
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.Print("Communicator found too little to read : " + buffersize.ToString() + " " + bufferreadpos.ToString() + " " + e.ToString());
                        onFailure("Insufficient data to read");
                        return;
                    }
                }
                catch (Exception e)
                {
                    Debug.Print("Communicator failure :" + e.ToString());
                    onFailure("Handle read comms failure : " + e.ToString());
                    return;
                }
            }
        }
开发者ID:kostaslamda,项目名称:win-xenguestagent,代码行数:79,代码来源:Communicator.cs

示例5: OnRecieve

        public void OnRecieve(IAsyncResult ar)
        {
            try
            {
                Socket clientSocket = (Socket)ar.AsyncState;
                clientSocket.EndReceive(ar);
                MessageBox.Show(clientSocket.ToString() + "\n" + clientSocket.SocketType.ToString() + "\n" + ar.AsyncState.ToString() + "\n" + ar.ToString());

                Data recMsg = new Data(byteData);

                Data sendMsg = new Data();

                byte[] msg;

                sendMsg.cmd = recMsg.cmd;
                sendMsg.user = recMsg.user;

                switch (recMsg.cmd)
                {
                    case Command.Login:
                        ClientInfo clientInfo = new ClientInfo();
                        clientInfo.socket = clientSocket;
                        clientInfo.user = recMsg.user;

                        clientList.Add(clientInfo);

                        sendMsg.Msg = ">> " + recMsg.user + " has joined the server \\o/";
                        break;

                    case Command.Logout:

                        int id = 0;
                        foreach (ClientInfo client in clientList)
                        {
                            if (client.socket == clientSocket)
                            {
                                clientList.RemoveAt(id);
                                break;
                            }
                            ++id;
                        }
                        clientSocket.Close();
                        sendMsg.Msg = ">> " + recMsg.user + " just left the server :c ";
                        break;

                    case Command.Message:
                        sendMsg.Msg = recMsg.user + ": " + recMsg.Msg;
                        break;

                    case Command.List:
                        sendMsg.cmd = Command.List;
                        sendMsg.user = null;
                        sendMsg.Msg = null;

                        foreach (ClientInfo client in clientList)
                        {
                            sendMsg.Msg += client.user + "*";
                        }

                        msg = sendMsg.toByte();

                        clientSocket.BeginSend(msg, 0, msg.Length, SocketFlags.None, new AsyncCallback(OnSend), clientSocket);
                        break;
                }
                if (sendMsg.cmd != Command.List)
                {
                    msg = sendMsg.toByte();
                    foreach (ClientInfo c in clientList)
                    {
                        if (c.socket != clientSocket || sendMsg.cmd != Command.Login)
                        {
                            c.socket.BeginSend(msg, 0, msg.Length, SocketFlags.None, new AsyncCallback(OnSend), c.socket);
                        }
                    }

                    tBox_log.Text += sendMsg.Msg + "\r\n";
                }

                if (recMsg.cmd != Command.Logout)
                {
                    clientSocket.BeginReceive(byteData, 0, byteData.Length, SocketFlags.None, new AsyncCallback(OnRecieve), clientSocket);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
开发者ID:csoty,项目名称:SimpleTCPChat,代码行数:88,代码来源:Form1_server.cs

示例6: onfinished

        private void onfinished(IAsyncResult ar)
        {
            if (ar.IsCompleted == false)
            {
                ActiveLogger.LogMessage("Thread finished with errors " + ar.ToString(), LogLevel.RecoverableError);
                return;
            }

            ITask task = ar.AsyncState as ITask;
            System.Diagnostics.Debug.Assert(task != null);

            lock (finished)
            {
                finished.Add(task);
            }
        }
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:16,代码来源:TaskProcessor.cs


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