小编bit*_*cle的帖子

C# 控制台应用程序 + 事件处理

大家好。我正在尝试了解如何在控制台应用程序中处理事件。我宁愿不使用静默的 WinForms(尽管我明白这是一种方法)来做到这一点。我已经阅读了一个类似的问题及其回应。请参阅下面的回复文本(链接):

STA 线程的基本要求是它需要运行消息泵。在 Windows 窗体中,您可以使用 Application.Run。或者您可以使用 user32!GetMessage 和 DispatchMessage 手动编写消息泵。但是在 WinForms 或 WPF 中使用它可能更容易。

使用“user32 -> GetMessage”和“user32 -> DispatchMessage”的程序的基本结构是什么?

c# console-application event-handling

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

CherryPy日志记录:如何配置和使用全局和应用程序级别记录器?

我在登录方面遇到了麻烦.我正在运行CherryPy 3.2并且我一直在阅读这里的文档,但是没有找到任何关于如何为输出配置本地日志文件以及如何写入它的示例.

Raspberry.py:


import socket
import sys
import cherrypy

app_roots = {
                # Sean's laptop dev environment.
                "mylaptop": "/home/src/local-mydomain.com/py",

                # Hosted dev environment.  
                "mydomain.com" : "/home/dev/src/py"
            }


hostname = socket.gethostname()
CherryPyLog = cherrypy.tree.mount().log

if hostname not in app_roots:
    CherryPyLog("The following hostname does not have an app_root entry in raspberry.py.  Exiting early.")
    sys.exit()

sys.stdout = sys.stderr
sys.path.append(app_roots[hostname])

import os
os.chdir(app_root)

# Setup for raspberry application logging.
import datetime
today = datetime.datetime.today()
log.access_file = "{0}/{1}.raspberry.access.log".format(app_roots[hostname],today.strftime("%Y%m%d-%H%M"))
log.error_file = "{0}/{1}.raspberry.error.log".format(app_roots[hostname],today.strftime("%Y%m%d-%H%M"))

#Testing logger …
Run Code Online (Sandbox Code Playgroud)

python logging cherrypy

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

sql异步查询问题

那么,为什么这不会成为回调函数呢?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace sqlAsyncTesting {
    public partial class Form1 : Form {

    public Form1() {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e) {
        using (SqlConnection conn = new SqlConnection(@"Data Source = bigapple; Initial Catalog = master; Integrated Security = SSPI; Asynchronous Processing = true;")) {
            conn.Open();
            SqlCommand cmd = new SqlCommand(@"WAITFOR DELAY '00:03'; Select top 3 * from sysobjects;", conn);
            IAsyncResult result …
Run Code Online (Sandbox Code Playgroud)

c# sql asynchronous

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

Vb6 UI自动化测试工具?

什么vb6 UI自动化测试工具可用?

另外,你会评价从1-10中列出的工具,其中10表示它是有史以来最神奇的工具,其中一个意味着它几乎不值得列出.

vb6 automation unit-testing

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

注册免费COM互操作:应用程序无法启动,因为它的并排配置不正确

背景.我有一个名为ComWrapper.dll的COM Wrapper程序集,用C#编写,Visual Basic 6应用程序名为Project1.exe.我添加了Project1.exe.manifest文件(其内容如下所示),我收到一条错误消息"应用程序无法启动,因为它的并排配置不正确.这是我的配置.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity type="win32"
                    name="Project1.exe"
                    version="1.0.0.0"
                    processorArchitecture="x86" />
  <dependency>
    <dependentAssembly>
      <assemblyIdentity name="ComWrapper" version="1.0.0.0" processorArchitecture="msil"></assemblyIdentity>
      <clrClass clsid="{3ac3d04e-1f83-4a27-b516-95e38126685d}" progid="MyComObjectNamespace.myclass" threadingModel="Both" name="MyComObjectNamespace.myclass" runtimeVersion=""></clrClass>
      <file name="ComWrapper.dll" hashalg="SHA1"></file>
      <dependency>
        <dependentAssembly>
          <assemblyIdentity name="mscorlib" version="2.0.0.0" publicKeyToken="b77a5c561934e089"></assemblyIdentity>
        </dependentAssembly>
      </dependency>
    </dependentAssembly>
  </dependency>
</assembly>
Run Code Online (Sandbox Code Playgroud)

任何帮助将非常感激.

c# vb6 com com-interop side-by-side

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

零mq pub/sub,multipart不工作

这是我的剧本.


#!/usr/bin/env python

import traceback
import sys
import zmq
from time import sleep

print "Creating the zmq.Context"
context = zmq.Context()

print "Binding the publisher to the local socket at port 5557"
sender = context.socket(zmq.PUB)
sender.bind("tcp://*:5557")

print "Binding the subscriber to the local socket at port 5557"
receiver = context.socket(zmq.SUB)
receiver.connect("tcp://*:5557")

print "Setting the subscriber option to get only those originating from \"B\""
receiver.setsockopt(zmq.SUBSCRIBE, "B")

print "Waiting a second for the socket to be created."
sleep(1)

print "Sending messages"
for i …
Run Code Online (Sandbox Code Playgroud)

python publish-subscribe zeromq

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

默认情况下是系统 PIP 而不是 virtualenv PIP?

在使用 virtualenv 和 pip off-and-on 几天后,我发现在 virtualenv 激活后使用的 PIP 版本是全局 PIP 而不是相对于该环境的 PIP;这样,如果您不设置 shell 环境变量export PIP_RESPECT_VIRTUALENV=true,pip 会将任何新包(例如 pip install argparse)安装到全局范围,而不仅仅是安装到 virtualenv。

如果激活了 virtualenv,我希望 PIP 默认安装到 virtualenv。

默认情况下它不以这种方式工作是否有原因?

有关工作原理,请参阅此处的说明PIP_RESPECT_VIRTUALENV

python pip virtualenv

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

Tornado RESTful PUT处理程序方法未获取请求参数

我正在尝试对RESTful API进行单元测试。这是我的API:


class BaseHandler(tornado.web.RequestHandler):                    
    def __init__(self, *args, **kwargs):                          
        tornado.web.RequestHandler.__init__(self, *args, **kwargs)
        self.log = self.application.log                           
        self.db = self.application.db                             

class ProductHandler(BaseHandler):
    @tornado.web.removeslash
    def put(self, id = None, *args, **kwargs):
        try:
            self.log.info("Handling PUT request")                                                             
            if not id:                                                                                                      
                raise Exception('Object Id Required')                                                                        
            id = { '_id' : id }                                                                                                                            
            new_values = dict()                                                                                             
            name = self.get_argument('name', None)                                                                          
            description = self.get_argument('description', None)                                                            
            if name:                                                                                                        
                new_values['name'] = name                                                                                   
            if description:                                                                                                 
                new_values['description'] = description                                                                     
            self.db.products.update(id, new_values, safe = True)                                                                                                               
        except:
            self.log.error("".join(tb.format_exception(*sys.exc_info())))                                                   
            raise                                                                                                           

 class Application(tornado.web.Application):                         
     def __init__(self, config_path, test …
Run Code Online (Sandbox Code Playgroud)

python rest tornado

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

关于epoll如何工作的一般解释?

我正在进行技术报告,从数据库轮询(通过同步存储过程调用)切换到消息队列(通过pub/sub).我希望能够解释如何轮询数据库与设置与AMQP代理的连接和配置消息处理程序有很大的不同和重要性.

有人可以在这里提供一个解释,或者指出一个关于epoll在通知套接字上可用的新数据时如何工作的高级教程?

python epoll file-descriptor rabbitmq

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

是否有可用于c ++的广泛使用的多处理抽象库?

我来自Python,全力以赴地进入C ++。而且,我最近想到的一个问题是:在C ++中是否有一个广泛使用的开源多处理抽象库?我正在考虑使多处理(ala fork)更易于管理的东西,类似于Python的多处理 stdlib库

我猜没有这样的东西。我完全希望有一个Boost :: Process,就像有一个Boost :: Thread一样

c++ fork multiprocessing

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