小编Dam*_*ien的帖子

在启动连接后将QTcpSocket移动到新线程

我有一个线程服务器.

需要在需要运行的线程上创建QTcpSocket,FI:Qt -通过传递套接字描述符在新线程中处理QTcpSocket.

我的问题是,我需要有一个线程池并在特定线程上移动套接字在客户端发送了一个特定的令牌后,该令牌定义了套接字需要的线程.

换句话说,我需要读取套接字以了解预先放置它的线程.

一些想法是首先绑定到QTcpSocket,读取,然后将描述符发送到线程并创建另一个QTcpSocket,但文档说:

注意:无法使用相同的本机套接字描述符初始化两个抽象套接字.

另一个解决方案是在一个单独的线程中创建套接字,然后将两个线程连接在一起,但我不知道是否可能.

或者也许能够在子线程上调用setSocketDescriptor之前读取主线程上的套接字描述符,如果可能的话?

qt qthread qtcpsocket

6
推荐指数
1
解决办法
940
查看次数

WFPSampler编译问题 - 找不到wfpcalloutsclassreg

在第36行的WFPSamplerCalloutDriver.InX上的任何设置(32/64 - 调试/发布)中,Microsoft演示WFPSampler项目的编译失败:

[ClassInstall32.nt$ARCH$]
   AddReg = WFPCalloutsClassReg
Run Code Online (Sandbox Code Playgroud)

:

Stamping .\WFPSamplerCalloutDriver.inf [Version] section with DriverVer=06/29/2017,19.37.54.422
sys\WFPSamplerCalloutDriver.inx(36-36): error 1203: Section [wfpcalloutsclassreg] not found.
sys\WFPSamplerCalloutDriver.inx(49-49): warning 2083: Section [defaultuninstall.ntx86] not referenced or used.
sys\WFPSamplerCalloutDriver.inx(53-53): warning 2083: Section [defaultuninstall.ntx86.services] not referenced or used.
sys\WFPSamplerCalloutDriver.inx(56-56): warning 2083: Section [wfpcalloutclassreg] not referenced or used.
sys\WFPSamplerCalloutDriver.inx(66-66): warning 2083: Section [wfpsamplercalloutdriver.nt.coinstallers] not referenced or used.
sys\WFPSamplerCalloutDriver.inx(70-70): warning 2083: Section [wfpsamplercalloutdriver.coinstaller.addreg] not referenced or used.
sys\WFPSamplerCalloutDriver.inx(73-73): warning 2083: Section [wfpsamplercalloutdriver.coinstaller.copyfiles] not referenced or used.
Run Code Online (Sandbox Code Playgroud)

安装程序使用Visual …

windows driver wdk visual-studio wfp

5
推荐指数
1
解决办法
207
查看次数

如何延迟像QTimer :: singleShot这样的C#Action?

Qt有一个简洁的功能,可以使用Lambda进行定时操作.

使用单行代码延迟后可以执行操作:

    QTimer::singleShot(10, [=](){
        // do some stuff
    });
Run Code Online (Sandbox Code Playgroud)

虽然我没有在C#中找到相同的东西.


我得到的最接近的是

Timer timer = new Timer();
timer.Interval = 10;
timer.Elapsed += (tsender, args) => { 
  // do some stuff 
  timer.Stop();
};
timer.Start();
Run Code Online (Sandbox Code Playgroud)

但它远非(视觉上)清洁.

有没有更好的方法来实现这一目标?

用例是将串行线路上的数据发送到某些硬件,点击或按下按钮时,通常需要在几毫秒后发送命令和数据包.


具有辅助功能的解决方案:

    public void DelayTask(int timeMs, Action lambda)
    {
        System.Timers.Timer timer = new System.Timers.Timer();
        timer.Interval = timeMs;
        timer.Elapsed += (tsender, args) => { lambda.Invoke(); };
        timer.AutoReset = false;
        timer.Start();
    }
Run Code Online (Sandbox Code Playgroud)

叫做

DelayTask(10, () => /* doSomeStuff...*/ );
Run Code Online (Sandbox Code Playgroud)

c#

5
推荐指数
2
解决办法
228
查看次数

标签 统计

c# ×1

driver ×1

qt ×1

qtcpsocket ×1

qthread ×1

visual-studio ×1

wdk ×1

wfp ×1

windows ×1