我的控制台应用程序在自己的线程中生成一个新的(不可见)窗口.在退出应用程序之前,它会尝试清理,并且GetMessage窗口消息泵中的最后一次调用失败. GetLastError返回1400,"无效的窗口句柄."
这是清理在应用程序线程中的进展:
if ( s_hNotifyWindowThread != NULL )
{
ASSERT(s_pobjNotifyWindow != NULL);
::PostMessage( s_pobjNotifyWindow->m_hWnd, WM_CLOSE, 0, 0 );
::WaitForSingleObject( s_hNotifyWindowThread, 50000L ); // Step 1: breakpoint here
::CloseHandle( s_hNotifyWindowThread ); // Step 4: breakpoint here
s_hNotifyWindowThread = NULL;
}
Run Code Online (Sandbox Code Playgroud)
这WndProc存在于为窗口创建的新线程中:
static LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch ( uMsg )
{
case WM_CLOSE:
::DestroyWindow( hWnd ); // Step 2: breakpoint here
break;
case WM_DESTROY:
::PostQuitMessage( 0 …Run Code Online (Sandbox Code Playgroud) 我有一个看起来像这样的数组:
a = [ -22 347 4448 294 835 4439 587 326]
Run Code Online (Sandbox Code Playgroud)
我想将其0或更小的值设置为-inf.我尝试了以下方法:
a[where(a <= 0)] = -inf
Run Code Online (Sandbox Code Playgroud)
当我这样做时,我收到错误:
OverflowError: cannot convert float infinity to integer
Run Code Online (Sandbox Code Playgroud)
知道为什么会这样,以及如何解决它?"where"函数应该返回小于或等于0的值的索引,并且赋值应该只将这些值设置为-inf.谢谢.
我们有一个数据库,其表格的值是从另一个系统导入的.有一个自动增量列,没有重复值,但缺少值.例如,运行此查询:
select count(id) from arrc_vouchers where id between 1 and 100
Run Code Online (Sandbox Code Playgroud)
应该返回100,但它返回87.有没有我可以运行的查询将返回缺失数字的值?例如,id为1-70和83-100的记录可能存在,但没有id为71-82的记录.我想返回71,72,73等
这可能吗?
我最近稳定了用Java编写的主要开源库的开发.然后我在服务器端发表了一篇文章,这给我带来了许多积极的(但也是批评性的,建设性的)反馈.并且是第一个贡献者,这太棒了!
因此,通过所有这些良好的反馈,我对我的项目有了很好的感觉,我创造了一些有用和原创的东西.我的项目背后的一些关键想法,以及为什么我认为它是原创的:
我认为这些关键想法对于特定类型的开发人员非常有用.特定的开发人员
现在是艰苦工作的开始.怎么引起注意?我怎样才能获得更多人群?我的项目如何变得相关?如何达到"特定类型的开发者"?
我希望能够创建具有可变精度的各种结构.例如:
public struct Point<T> where T : INumber
{
public T X;
public T Y;
public static Point<T> operator +(Point<T> p1, Point<T> p2)
{
return new Point<T>
{
X = p1.X+p2.X,
Y = p1.Y+p2.Y
};
}
}
Run Code Online (Sandbox Code Playgroud)
我知道Microsoft通过创建两个结构来处理这个问题 - Point(对于整数)和PointF(对于浮点数),但是如果你需要一个基于字节的点或双精度,那么你将被要求复制很多旧的代码,只是更改值类型.
我有一个看起来像这样的方法:
protected void OnBarcodeScan(BarcodeScannerEventArgs e)
{
// We need to do this on a seperate thread so we don't block the main thread.
ThreadStart starter = () => SendScanMessage(e, _scanDelegates);
Thread scanThread = new Thread(starter);
scanThread.Start();
}
Run Code Online (Sandbox Code Playgroud)
然后线程关闭并执行一些逻辑(并最终在我的测试中调用委托).
我的问题是我的单元测试在线程完成之前完成.所以我的测试失败了.
我可以加入System.Threading.Thread.Sleep(1000);并希望逻辑永远不会超过一秒(它不应该).但这似乎是一个黑客.
问题是我不想将该线程暴露给外部世界甚至暴露给其他类.
是否有一些很酷的方法来再次找到该线程并在我的单元测试中等待它?
像这样的东西:
[TestMethod]
[HostType("Moles")]
public void AddDelegateToScanner_ScanHappens_ScanDelegateIsCalled()
{
// Arrange
bool scanCalled = false;
MCoreDLL.GetTopWindow = () => (new IntPtr(FauxHandle));
// Act
_scanner.AddDelegateToScanner(_formIdentity, ((evnt) => { scanCalled = true; }));
_scanner.SendScan(new BarcodeScannerEventArgs("12345678910"));
// This line is fake! …Run Code Online (Sandbox Code Playgroud) 我正在阅读如何学习Python的艰难之路,它使用2.最近发现的使用Python的Invent,它使用3.
我可以下载python 3,并在阅读Invent With Python时使用它,然后当我想阅读如何学习Python的艰难之路时切换回python 2.如果是这样,我如何选择使用哪个版本?
我有一个UIView作为属性的类.有时我传入UILabel; 有时是UITextField.无论我传入哪个,我都希望课程设置文本.目前我这样做,这有效:
if ([self.viewToUpdate respondsToSelector:@selector(setText:)] && !self.newAnswer)
[self.viewToUpdate setText:[[self.choices objectAtIndex:indexPath.row] text]];
Run Code Online (Sandbox Code Playgroud)
问题是,这给出了警告,因为即使我正在检查respondsToSelector,Xcode也不知道我的UIView会响应setText:.如何删除此警告?
我知道我可以专门检查它是TextField还是Label,然后分别转换为TextField或Label,但这会很痛苦,如果我有更多类型的视图,我会有为每一个添加几行代码.
我想创建自己的协议,然后让我的类有id作为viewToUpdate的类型...但当然UITextField和UILabel不符合该协议...
我正在尝试为自动构建设置CruiseControl.NET 1.5.7256.1.我的项目存储在Mercurial中,我使用以下内容ccnet.config:
<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
<project name="Slider" webURL="http://localhost/ccnet">
<triggers>
<intervalTrigger seconds="3600" />
</triggers>
<sourcecontrol type="hg" autoGetSource="true">
<executable>C:\Python26\Scripts\hg.bat</executable>
<repo>c:\repos\slider</repo>
<workingDirectory>c:\ccnet\slider</workingDirectory>
</sourcecontrol>
<tasks>
<msbuild>
<executable>C:\Windows\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe</executable>
<workingDirectory>c:\ccnet\slider</workingDirectory>
<projectFile>Slider.sln</projectFile>
<buildArgs>/noconsolelogger /p:Configuration=Debug /v:diag</buildArgs>
<targets>Slider</targets>
<timeout>900</timeout>
<logger>C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
</tasks>
</project>
</cruisecontrol>
Run Code Online (Sandbox Code Playgroud)
但是当我强制构建时,我收到此错误:
[Slider:WARN] Source control failure (GetModifications): Source control operation failed: < was unexpected at this time.
. Process command: C:\Python26\Scripts\hg.bat log -r 0:123 --template <modification><node>{node|short}</node><author>{author|user}</author><date>{date|rfc822date}</date><desc>{desc|escape}</desc><rev>{rev}</rev><email>{author|email|obfuscate}</email><files>{files}</files></modification> --noninteractive
[Slider:INFO] Integration complete: Exception - 12/2/2010 1:19:08 PM
Run Code Online (Sandbox Code Playgroud)
该错误可能是由--template参数中的未引用尖括号引起的,但是如何让CC.NET在该参数周围加上引号呢?
===============
这是hg.bat:
@echo off
rem …Run Code Online (Sandbox Code Playgroud) 所以我采取了升级到Xcode 3.2.5(iPhone SDK 4.2)的步骤,现在我无法运行到设备.我现在总是在开发环境中看到这个:

在我目前的项目中,当进入项目设置时,我只能将Base SDK设置为iOS 4.2,但这不会改变"Base SDK Missing"问题.:/
然而,我可以部署到模拟器,并更改我希望模拟器加载的版本.
有谁知道如何解决这一问题?
如果我创建一个新项目,我不会得到这个......
谢谢
c# ×2
ios ×2
python ×2
xcode ×2
c++ ×1
exception ×1
generics ×1
ios4 ×1
iphone ×1
jooq ×1
mercurial ×1
mysql ×1
numpy ×1
objective-c ×1
open-source ×1
python-2.6 ×1
python-3.x ×1
scipy ×1
sql ×1
unit-testing ×1