zoukankan      html  css  js  c++  java
  • 【转】MaxScript.Net接收本地端口的消息执行

    MaxScript里开不了线程,但是可以用.Net的BackgroundWorker来做后台处理 BackgroundWorker

    Fn BackgroundTcpListenerDoWork theSender theEvent = 
    (
        IPAddress = DotNetClass "System.Net.IPAddress"
        theIPAddress = IPAddress.Parse "127.0.0.1"
        theTcpListener = DotNetObject "System.Net.Sockets.TcpListener" theIPAddress 7457
        theTcpListener.Start()
    
    while not theSender.CancellationPending do
        (
            theSocket = theTcpListener.AcceptSocket()
            theByteStream = DotNetObject "System.Byte[]" 8192
            theSocket.Receive theByteStream
    Encoding
    = DotnetClass "System.Text.Encoding" theString = Encoding.UTF8.GetString(theByteStream) if not theSender.CancellationPending do Execute theString ) theTcpListener.Stop() ) BackgroundWorker = DotNetObject "System.ComponentModel.BackgroundWorker" DotNet.AddEventHandler BackgroundWorker "DoWork" BackgroundTcpListenerDoWork BackgroundWorker.WorkerSupportsCancellation = true BackgroundWorker.RunWorkerAsync() /* BackgroundWorker.CancelAsync() BackgroundWorker.Dispose() */

    【转】http://www.xuebuyuan.com/429604.html

  • 相关阅读:
    GDOI 2019 退役记
    SHOI2019 游记
    【WC2014】紫荆花之恋
    PKUWC 2019 & NOIWC2019 比赛总结 Formal Version
    WC 2019 颓废记
    VDUVyRLYJC
    Git学习
    DOM学习笔记
    python基础---->AJAX的学习
    python基础---->进程、线程及相关等
  • 原文地址:https://www.cnblogs.com/lged/p/5551351.html
Copyright © 2011-2022 走看看