标签: blocking

Windows:如何显示非阻塞警报/确认窗口?

我想实现一个简单的确认/警报框,可以通过 CLI 使用 Windows XP/Vista 批处理脚本调用它。

标准警报框似乎被阻塞,这意味着整个批处理脚本将在警报窗口调用时停止,这不是我想要的。

如果需要编码,请提供示例或文档。语言可以是任何可编译的语言,中间不需要虚拟机。

windows alert batch-file confirmation blocking

3
推荐指数
1
解决办法
3484
查看次数

在C中接收时发送

我在我的服务器上创建了一段代码作为多线程

问题是,当我在另一个套接字上接收时,它不会发送数据.

因此,如果我向客户端2发送一些内容到客户端2,则client2仅在他自己发送内容时才会收到(跳出recv函数)..我该如何解决这个问题?

 /* Thread*/
while (! stop_received) {
        nr_bytes_recv = recv(s, buffer, BUFFSIZE, 0);

        if(strncmp(buffer, "SEND", 4) == 0) {
            char *message = "Text asads \n";
            rv = send(users[0].s, message, strlen(message), 0);
            rv = send(users[1].s, message, strlen(message), 0);
            if (rv < 0) {
                perror("Error sending");
                exit(EXIT_FAILURE);
            }           
        }else{
            char *message = "Unknown command \n";
            rv = send(s, message, strlen(message), 0);
            if (rv < 0) {
                perror("Error sending");
                exit(EXIT_FAILURE);
            }
        }
}
Run Code Online (Sandbox Code Playgroud)

c sockets blocking

3
推荐指数
1
解决办法
2099
查看次数

阻塞和非阻塞读取有什么区别?

将等待/无等待指示符的概念添加到上述问题中作为TCP/IP或UDP环境中的ReadMessage函数的参数.

第三方功能描述指出:

此函数用于从队列中读取消息,该队列由先前的registerforinput调用定义.输入等待/无等待指示符将确定此函数是否将阻止指定的队列,等待数据放在队列中.如果指定了nowait选项且没有可用数据,则会将NULL指针返回给调用者.当可用数据时,此函数将返回指向从队列读取的数据的指针.

函数阻塞或非阻塞是什么意思?

c++ multithreading nonblocking blocking

3
推荐指数
2
解决办法
9230
查看次数

当您调用事件时,事件是阻塞的还是非阻塞的?

假设我有一个事件Tick,我称之为:

public class Test
{
    public event Action Tick;

    public void Test()
    {
         Tick();
         Console.WriteLine("Tick Finished");
    }
}
Run Code Online (Sandbox Code Playgroud)

如果我订阅了大量事件Tick,那么正在运行的该线程的操作是否会Test()被阻止,直到它们全部被调用为止,还是异步执行此操作?

c# events multithreading blocking

3
推荐指数
1
解决办法
5489
查看次数

具有阻塞 IO 客户端、浏览器的 Netty

我有一个使用传统 BIO(阻塞 IO)的遗留应用程序(HTTP 和原始 TCP),我想开始用 Netty 替换它。

Netty 如何与传统的 BIO 客户端一起工作?如果我先用 Netty 替换服务器组件并保留 BIO 客户端,会不会有任何问题?

此外,Netty 构建的服务器能否取代用于为浏览器客户端提供服务的典型 HTTP Web 服务器?有什么问题吗?

谢谢

browser io blocking netty

3
推荐指数
1
解决办法
3934
查看次数

使用WshShell.Exec()方法调用Powershell会挂起脚本

我试图用WshShell对象的Exec方法调用Powershell.我正在用JScript编写脚本,但我也在VBScript中重现了这个问题.以下两个简短的测试脚本都会导致WSH无限期挂起:

test.js

var shell = new ActiveXObject("WScript.Shell");
WScript.Echo(shell.exec("powershell -Command $Host.Version; Exit").StdOut.ReadAll());
Run Code Online (Sandbox Code Playgroud)

test.vbs

dim shell

set shell = CreateObject("WScript.Shell")
WScript.Echo shell.exec("powershell -Command $Host.Version; Exit").StdOut.ReadAll
Run Code Online (Sandbox Code Playgroud)

我做错了什么,或者我遇到了限制/不兼容?Run方法工作得很好,但是我需要捕获它无法做到的输出.

编辑:我忘了提到我的平台是Windows 7 Pro,64位使用PowerShell 3.我已经在Windows XP上使用PowerShell 1进行了测试.

编辑2:我已经更新了我正在运行的测试脚本以符合x0n的答案.不幸的是,我仍然遇到麻烦.这是我目前的测试:

test.js:

var shell = new ActiveXObject("WScript.Shell");
WScript.Echo(shell.exec('powershell -noninteractive -noprofile -Command "& { echo Hello_World ; Exit }"').StdOut.ReadAll());
Run Code Online (Sandbox Code Playgroud)

test.vbs:

dim shell

set shell = CreateObject("WScript.Shell")
WScript.Echo shell.exec("powershell -noninteractive -noprofile -Command ""& { echo Hello_World ; Exit }""").StdOut.ReadAll
Run Code Online (Sandbox Code Playgroud)

powershell wsh exec blocking

3
推荐指数
1
解决办法
7585
查看次数

没有获得fgets()函数的预期输出

这里简单的代码我没有得到预期的输出.

#include<stdio.h>

int main()
{
   char buf[1024];
   while(1)
   {
      fgets(buf,strlen(buf),stdin);
      printf("%s",buf);
      printf("hello");
   }
}
Run Code Online (Sandbox Code Playgroud)

在上面的代码中,我想要从键盘输入的字符串打印出来,然后打印出来,然后你好.据我所知fgets()是一个阻塞函数,直到我从键盘输入一个字符串并按下ENTER键,它将阻止程序直到那个时间.因此,当我运行它时,我期望它如下

$ ./a.out
I input some text here <ENTER>
I input some text here 
hello
Run Code Online (Sandbox Code Playgroud)

但实际上我得到的输出是在终端上打印的无限循环"你好".为什么我的fgets()没有阻止该程序?任何的想法?

c fgets blocking

3
推荐指数
1
解决办法
1023
查看次数

SerialPort.Read(byte [],int32,int32)没有阻塞但我想要它 - 我该如何实现?

我正在编写一个与一台测试设备交谈的界面.设备通过串行端口进行通信,并以发送的每个命令以已知的字节数进行响应.

我目前的结构是:

  • 发送命令
  • 读回指定字节数
  • 继续申请

但是,当我使用SerialPort.Read(byte [],int32,int32)时,该函数没有阻塞.因此,例如,如果我调用MySerialPort.Read(byteBuffer, 0, bytesExpected);,则函数返回的值小于指定的数量bytesExpected.这是我的代码:

public bool ReadData(byte[] responseBytes, int bytesExpected, int timeOut)
{
    MySerialPort.ReadTimeout = timeOut;
    int bytesRead = MySerialPort.Read(responseBytes, 0, bytesExpected);
    return bytesRead == bytesExpected;
}
Run Code Online (Sandbox Code Playgroud)

我将此方法称为:

byte[] responseBytes = new byte[13];
if (Connection.ReadData(responseBytes, 13, 5000))
    ProduceError();
Run Code Online (Sandbox Code Playgroud)

我的问题是,我似乎无法像我所说的那样读取完整的13个字节.如果我Thread.Sleep(1000)在我的SerialPort.Read(...)一切正常之前放好了.

Read在超出timeOut或读取指定的字节数之前,如何强制方法阻塞?

c# serial-port blocking

3
推荐指数
1
解决办法
6855
查看次数

使用Meteor帐户禁止系统?

我正在使用使用accounts-ui和accounts-twitter的meteor进行聊天应用.我希望能够禁止人们滥用网站,但我不确定如何做到这一点,或者甚至可能.有没有办法做到这一点?这是我用来运行聊天应用程序部分的代码:

ui.js:

// render all of our messages in the ui
Template.chatBox.helpers({
  "messages": function() {
    return chatCollection.find();
  }
});

// get the value for handlerbar helper user
Template.chatMessage.helpers({
  "user": function() {
    if(this.userId == 'me') {
      return this.userId;
    } else if(this.userId) {
      getUsername(this.userId);
      return Session.get('user-' + this.userId);
    } else {
      return 'anonymous-' + this.subscriptionId;
    }
  }
});

// when Send Chat clicked at the message to the collection
Template.chatBox.events({
    "click #send": function() {
            if (Meteor.user() == null) {
              alert("You must login …
Run Code Online (Sandbox Code Playgroud)

javascript twitter account blocking meteor

3
推荐指数
1
解决办法
1468
查看次数

python apscheduler不一致

我正在使用调度蟒蛇 apschedulerweb.py框架。该功能runserver应该每天上午9点运行,但是不一致。它运行大多数天,但有时会跳过一天。

码:

import web
from apscheduler.schedulers.blocking import BlockingScheduler #Blocking Scheduler

#URLs
urls = (
    '/startscheduler/','index',
    )

Nightlysched = BlockingScheduler()

@Nightlysched.scheduled_job('cron', hour=9)
def runserver():
    print 2+2 #doing some calculations here

#Main function to run the cron JOB
if __name__ == "__main__":
    Nightlysched.start() #stating the job
    app = web.application(urls, globals())
    app.run() 
Run Code Online (Sandbox Code Playgroud)

将调度程序配置为每天上午9点运行的正确方法是什么?

python scheduler blocking web.py apscheduler

3
推荐指数
1
解决办法
2561
查看次数