小编Sco*_*ain的帖子

用户注释如何工作?

我仍然是Java编程的新手,我正在查看一个开源项目并遇到了这个问题

public @TileNetworkData int progressPart = 0;   
Run Code Online (Sandbox Code Playgroud)

我已经看过@以前的使用,但只是做@override成员之前的事情.令我惊讶的是查找了它带给我用户代码的定义

import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface TileNetworkData {

    int staticSize () default -1; 

}
Run Code Online (Sandbox Code Playgroud)

这段代码在做什么,它有什么用呢?看起来它正在向该字段添加某种形式的元数据.这是怎么回事?

做一些谷歌我发现这被称为"注释",但所有附加到它上面的东西都超出了我的想象.任何类似于此类事例的例子都将受到赞赏.

java annotations

9
推荐指数
1
解决办法
789
查看次数

如何与"row_number()结束相反(按[Col]顺序分隔[Col])"

我试图在数据表中组合重复的条目,并给他们一个新的数字.

这是一个示例数据集(可运行的副本)

declare @tmpTable table
    (ID Varchar(1), 
     First varchar(4), 
     Last varchar(5), 
     Phone varchar(13),
     NonKeyField varchar(4))

insert into @tmpTable select 'A', 'John', 'Smith', '(555)555-1234', 'ASDF'
insert into @tmpTable select 'B', 'John', 'Smith', '(555)555-1234', 'GHJK'
insert into @tmpTable select 'C', 'Jane', 'Smith', '(555)555-1234', 'QWER'
insert into @tmpTable select 'D', 'John', 'Smith', '(555)555-1234', 'RTYU'
insert into @tmpTable select 'E', 'Bill', 'Blake', '(555)555-0000', 'BVNM'
insert into @tmpTable select 'F', 'Bill', 'Blake', '(555)555-0000', '%^&*'
insert into @tmpTable select 'G', 'John', 'Smith', '(555)555-1234', '!#RF' …
Run Code Online (Sandbox Code Playgroud)

sql sql-server sql-server-2005 row-number

9
推荐指数
1
解决办法
3707
查看次数

干净地中断HttpListener的BeginGetContext方法

我正在使用HttpListener并使用BeginGetContext来获取我的上下文对象.我想干净地关闭我的HttpListener但是如果我尝试在侦听器上执行Close操作,我会得到一个异常,它会导致我的程序退出.

using System;
using System.Net;

namespace Sandbox_Console
{
    class Program
    {
        public static void Main()
        {
            if (!HttpListener.IsSupported)
            {
                Console.WriteLine("Windows XP SP2 or Server 2003 is required to use the HttpListener class.");
                return;
            }

            // Create a listener.
            HttpListener listener = new HttpListener();
            listener.Prefixes.Add("http://vwdev.vw.local:8081/BitsTest/");
            listener.Start();
            Console.WriteLine("Listening...");

            listener.BeginGetContext(Context, listener);
            Console.ReadLine();

            listener.Close(); //Exception on this line, but not shown in Visual Studio
            Console.WriteLine("Stopped Listening..."); //This line is never reached.
            Console.ReadLine();

        }

        static void Context(IAsyncResult result)
        { …
Run Code Online (Sandbox Code Playgroud)

.net c# .net-4.0 httplistener

9
推荐指数
1
解决办法
5575
查看次数

为什么我的表格没有锁定?

在从另一个问题中阅读这个答案时,我100%确定以下代码会锁定UI并且不会导致任何移动.

private void button1_Click(object sender, EventArgs e)
{
    for (int i = 0; i < 5; i++)
    {
        this.Left += 10;
        System.Threading.Thread.Sleep(75);
        this.Left -= 10;
        System.Threading.Thread.Sleep(75);
    }
}
Run Code Online (Sandbox Code Playgroud)

我和评论中的其他几个人说它不起作用,但OP坚持认为它确实如此,我们应该尝试.我最终创建了一个新的Winforms项目,添加了一个按钮,然后将上面的代码放在事件处理程序中进行单击,表单确实发生了变化.

当此方法阻止消息泵时表单是如何移动的,OnPaint不应该在表单上调用,也不能在其任何子控件上调用,这是如何工作的?

.net c# winforms

9
推荐指数
1
解决办法
165
查看次数

HttpClient.GetStringAsync(url)抛出"底层连接已关闭:发送时发生意外错误".Windows 8.1 C#

我正在创建一个新的Windows 8.1应用程序,只是为了测试我得到的这个错误.该应用程序只有一个功能:

private async void TestMethod()
        {
            try
            {                       
                HttpClient httpClient = new HttpClient();
                HttpResponseMessage response = await httpClient.GetAsync("https:// url ");                    
            }
            catch (HttpRequestException e)
            {
                string s = e.InnerException.Message;
            }
        }
Run Code Online (Sandbox Code Playgroud)

它始终进入捕获并抛出"底层连接已关闭:发送时发生意外错误".我发现很多问题都提到了,但没有解决方案对我有用,因为这是Windows 8.1 Store应用程序而不是ASP.NET应用程序.

我正在使用的Uri在浏览器中打开并且运行良好.

我甚至得到了这篇文章:https://support.microsoft.com/en-us/kb/915599但没有解决方案.以前有人遇到过这个问题吗?

编辑:

我改变了使用方法 async Task

System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection …

c# exception httpclient windows-8.1

9
推荐指数
1
解决办法
4596
查看次数

是否有可能等待空文字?

你可以等待 C#5+中的任何内容,只要该类型具有一个被调用的函数.GetAwaiter(),它返回一个特殊对象或者具有相同的扩展方法.

Unity3d在其下一个主要版本中将支持async/await.目前在Unity3d中你可以yield return null;在一个协程里面代表"等待下一帧".

我想知道是否有可能制作一个扩展方法,允许你做await null;同样的行为.没有System.Null像有一个System.Void,所以我想不出在扩展方法中放入什么类型.

.net c# asynchronous async-await

9
推荐指数
2
解决办法
3310
查看次数

有一个可选参数,需要另一个参数

很简单,我如何初始化params我的Powershell脚本部分,以便我可以使用命令行参数

Get-Foo [-foo1] <foo1Arg> [-foo2 <foo2Arg> [-bar <barArg>]]
Run Code Online (Sandbox Code Playgroud)

所以我唯一可以使用的-bar是何时foo2定义.

如果-bar不依赖-foo2我就可以做到

[CmdletBinding()]
param (
    [Parameter(Mandatory=$true)]
    [string]$foo1,

    [string]$foo2,

    [string]$bar
)
Run Code Online (Sandbox Code Playgroud)

但是,我不知道如何做出这个依赖参数.

powershell powershell-2.0

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

如何抑制由我​​无法更改的代码显示的对话框?

我有来自第三方的Inproc COM服务器.如果它捕获特定类型的错误,我调用的函数之一将显示错误消息对话框.问题是我正在尝试批量处理数据,而我使用的数据源导致错误对话框弹出很多.如果它生成了1000个对话框,这不会成为问题,而是它会阻塞,直到您按OK才会返回该功能.

在此输入图像描述

如何禁止显示对话框,或以编程方式按OK?

这是一个调用堆栈的副本,​​因为它正在等待我按OK

    [Managed to Native Transition]  
>   System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData) Line 2198 + 0x1e bytes   C#
    System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context) Line 3422 + 0x1b bytes C#
    System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) Line 3306 + 0xc bytes   C#
    System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm) Line 1495 + 0x31 bytes    C#
    UniversalDataImporter.exe!UniversalDataImporter.Program.Main() Line 18 + 0x1d bytes C#
    [Native to Managed Transition]  
    [Managed to Native Transition]  
    mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args) Line 2023 + 0x18 bytes  C#
    Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() + 0x27 bytes  
    mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object …

.net c# com messagebox .net-4.0

8
推荐指数
1
解决办法
7990
查看次数

用户模式应用程序和内核模式驱动程序之间的双向交互?

我即将撰写以下互动:

  • 当有一个即将启动的进程时,驱动程序将通知用户应用程序,然后它将等待应用程序的响应.

  • 应用程序将决定是否允许正常创建或立即终止该过程,并将其决定发送回驱动程序.

  • 基于用户应用程序的决定.然后,驱动程序将允许或阻止进程执行.

我的问题是:从驱动程序通知用户模式应用程序然后让驱动程序等待响应的建议方法是什么?

windows kernel driver process

8
推荐指数
1
解决办法
1900
查看次数

有没有办法在Powerhell中转义字符串,比如C#中的@"string"

是否有办法逃避完整的字符串i powershell与@"字符串"在C#中的工作方式相同我正在编写一个脚本,在那里我有几个字符串,如下所示:D:(A ;; CCLCSWRPWPDTLOCRRC ;;; SY )(A ;; CCDCLCSWRPWPDTLOCRSDRCWDWO ;;; BA)(A ;; CCLCSWLOCRRC ;;; AU)(A ;; CCLCSWRPWPDTLOCRRC ;;; PU)

一个接一个地逃跑回家路还很远

powershell

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