相当简单的问题.在SQL 2008中,如果我有一个存储过程(见下文),我是否在前两个语句之间存在竞争条件的风险,或者存储过程是否锁定了事务所涉及的事情?
ALTER PROCEDURE [dbo].[usp_SetAssignedTo]
-- Add the parameters for the stored procedure here
@Server varchar(50),
@User varchar(50),
@UserPool varchar(50)
AS
BEGIN
SET NOCOUNT ON;
Declare @ServerUser varchar(50)
-- Find a Free record
SELECT top 1 @ServerUser = UserName
from ServerLoginUsers
where AssignedTo is null and [TsServer] = @Server
--Set the free record to the user
Update ServerLoginUsers
set AssignedTo = @User, AssignedToDate = getdate(), SourcePool = @UserPool
where [TsServer] = @Server and UserName = @ServerUser
--report record back if …Run Code Online (Sandbox Code Playgroud) t-sql sql-server concurrency stored-procedures sql-server-2008
很简单,我如何初始化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)
但是,我不知道如何做出这个依赖参数.
我有来自第三方的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 … 我正在使用带有WCF的Streaming,我有一个关于" 启用异步流 " 的段落的含义的问题来自MSDN关于WCF中的大数据和流的文章.
要启用异步流,请将
DispatcherSynchronizationBehavior端点行为添加 到服务主机并将其AsynchronousSendEnabled属性设置为true.我们还在发送端添加了真正异步流的功能.这提高了服务的可扩展性,在这种情况下,它将消息流式传输到多个客户端,其中一些客户端可能由于网络拥塞或根本不读取而导致读取速度缓慢.在这些场景中,我们现在不会阻止每个客户端的服务上的单个线程.这确保了服务能够处理更多客户端,从而提高了服务的可扩展性.
我明白上面的意思是我补充说
<behaviors>
<endpointBehaviors>
<behavior name="AsyncStreaming">
<dispatcherSynchronization asynchronousSendEnabled="true" />
</behavior>
</endpointBehaviors>
...
Run Code Online (Sandbox Code Playgroud)
对于我的web.config文件并引用AsyncStreaming我的端点中的行为,但是我不明白为这些步骤完成了什么.我是否需要修改我的代码才能利用这种异步性?
同样在一个类似的主题上(但是如果它太不同了我会把它转移到一个新问题),在WCF中使用Streams使用async/await效果怎么样?我可以Task<Stream> Foo()签订服务合同吗?我做了一些数据库调用,其结果我最终将包装到我将从WCF服务返回的自定义流中.能够使用ExecuteDataReaderAsync()非常有用的东西,在处理流式传输而不是缓冲消息时,我仍然可以使用它吗?
我测试了它,我知道它"工作"使用任务但我不知道是否这样做会导致函数回退到"缓冲"模式,就像你为函数提供多个参数一样(参见第3段) " 流传输的编程模型 "在同一个MSDN页面上),我不知道如何检查是否发生了这种情况.
我正在使用asp.net web api 2和Entity Framework 6.
原始的伪代码
public IHttpActionResult GetProductLabel(int productId)
{
var productDetails = repository.GetProductDetails(productId);
var label = labelCalculator.Render(productDetails);
return Ok(label);
}
Run Code Online (Sandbox Code Playgroud)
修改代码
public async Task<IHttpActionResult> GetProductLabel(int productId)
{
var productDetails = await repository.GetProductDetailsAsync(productId); // 1 long second as this call goes into sub services
var label = labelCalculator.Render(productDetails); // 1.5 seconds synchrounous code
return Ok(label);
}
Run Code Online (Sandbox Code Playgroud)
在我改变之前,一切都是同步的.
在我改变之后,对再次调用数据库的远程服务的调用是以async-await方式完成的.
然后我对一个只提供同步方法的渲染库进行同步调用.计算需要1.5秒.
还有一个好处,我做远程database_service调用async-await方式,但第二个调用不?还有什么我还能改进的吗?
注意
我问这个的原因是因为:
"当进程等待I/O完成时,使用异步控制器,它的线程被释放,供服务器用于处理其他请求."
所以当第一个远程database_service调用正在处理并等待1秒时,该线程将返回给IIS ?? !!
但是第二个标签计算需要1.5秒才能再次阻止当前线程1.5秒?
所以我发布并阻止线程,这没有意义或你怎么想?
我创建了一个简单的MVC4应用程序并注册了一个用户.usrname和密码存储在名为AspNetUsers的表中.该表没有盐场.
我理解的方式是当用户登录时; 他们输入用户名和密码.然后将盐与输入的密码连接起来,并与数据库中的密码进行比较.这不正确吗?即
Hash(PasswordEntered) + Salt = Password in database = authenticated
Hash(PasswordEntered) + Salt <> Password in database = not authenticated
Run Code Online (Sandbox Code Playgroud)
有一个名为:aspnetusers.SecurityStamp的字段,但我的研究告诉我,这不是Salt.
更新
我刚读过Scott Chamberlain.请参阅以下步骤:
1)用户在注册期间输入:Hello123作为密码,Salt(随机生成)为:456,然后输入PasswordHash的密码为:Hello123 + 456 2)然后用户尝试登录并输入Hello123(正确)作为密码.盐(随机生成)为:567.因此Hello123 + 456与Hello123 + 567进行比较,验证失败.
在这种情况下,用户输入正确的密码并且未经过身份验证.我显然缺少一些基本的东西.
我有一个第三方库在内部执行某些操作,导致它在连接调试器时大大减慢,即使在发布模式下也是如此.
我已经找到了100个关于如何在Visual Studio中手动分离调试器的解释Debug -> Detach process.但是,我还没有看到任何人提供一个示例,其中程序可以将任何附加的调试器分离给自己.
基本上是Debugger.Launch()的分离版本?
我有一个用C#编写的新程序,它需要读写与vb6二进制格式兼容的二进制文件.我无法更改vb6程序,但我可以更改我的程序.
我有一切工作,除了我对字符串有点不确定.
如果我在vb6中写下以下内容
Private Type PatchRec
string As String
End Type
Private Sub Command1_Click()
Dim intFileNum As Integer
Dim recTest As TestRec
intFileNum = FreeFile
Open "E:\testing" & "\" & "testfile" & ".bin" For Binary Access Write As #intFileNum
recTest.string = "This is a test string"
Put #intFileNum, , recPatch
Close #intFileNum
End Sub
Run Code Online (Sandbox Code Playgroud)
我在C#中写下以下内容
public static void Main(params string[] args)
{
using(var fs = new FileStream("test.bin", FileMode.Create, FileAccess.ReadWrite))
using (var bw = new BinaryWriter(fs))
{
string str = "This …Run Code Online (Sandbox Code Playgroud) 我试图弄清楚如何使用与VB相同的隐式定义将以下示例代码转换为C#.我知道我可以将按钮和通用控件定义为两个对象并使其工作,但我想在C#中使用相同的变量"ctlHTML"就像VB一样.有人可以帮忙吗?
Sub MySub(varInput As String, pnl As Panel)
Dim ctlHTML = Nothing
Select Case varInput
Case "btn"
ctlHTML = New HtmlButton
Case "lbl"
ctlHTML = New HtmlGenericControl()
End Select
With ctlHTML
.Style.Add("font-size", "14px")
End With
pnl.Controls.Add(ctlHTML)
End Sub
Run Code Online (Sandbox Code Playgroud) 我试图做类似的事情:
public interface IView<T> : T where T : class
{
T SomeParam {get;}
}
Run Code Online (Sandbox Code Playgroud)
这样我以后就可以了
public class SomeView : IView<ISomeView>
{
}
Run Code Online (Sandbox Code Playgroud)
是否有可能以这种方式使用泛型指定继承,或者我必须走很长的路并在定义类时显式指定两个接口并执行:
public interface IView<T>
{
T SomeParam {get;}
}
public class SomeView : IView<ISomeView>, ISomeView
{
}
Run Code Online (Sandbox Code Playgroud) c# ×8
.net ×2
asp.net ×2
async-await ×2
asynchronous ×2
.net-4.0 ×1
com ×1
concurrency ×1
debugging ×1
generics ×1
inheritance ×1
messagebox ×1
powershell ×1
sql-server ×1
streaming ×1
t-sql ×1
vb.net ×1
vb.net-to-c# ×1
vb6 ×1
wcf ×1