我在初始化时完全加载了一个java HashMap,但在初始化之后,多个线程将从HashMap中读取数据.我想避免任何类型的同步,因为地图基本上是只读的,永远不会改变.但我可以保证所有线程都可以看到所有键和值吗?
我有一个aspx页面来进行异步调用.页面从数据库获取数据(在存储过程中花费30秒),然后将结果返回给客户端.这是通过jquery帖子完成的.
问题是,虽然它执行存储过程30秒,但我的网站的其余部分无法发出任何请求.
我有<%@ Page Async="true" AsyncTimeout="600" Language="C#"....aspx
我的.aspx.cs包含:
private SqlConnection _connection;
private SqlCommand _command;
private SqlDataReader _reader;
protected void Page_Load(object sender, EventArgs e)
{
AddOnPreRenderCompleteAsync(BeginAsyncOperation, EndAsyncOperation);
}
protected IAsyncResult BeginAsyncOperation(object sender, EventArgs e, AsyncCallback cb, object state)
{
IAsyncResult result = null;
try
{
SqlConnectionStringBuilder ConnectionStringBuilder = new SqlConnectionStringBuilder("**MyConnectionStringGoesHere**");
ConnectionStringBuilder.AsynchronousProcessing = true;
_connection = new SqlConnection(ConnectionStringBuilder.ConnectionString);
_command = new SqlCommand("GetSiteUpdates", _connection) { CommandType = CommandType.StoredProcedure };
_connection.Open();
result = _command.BeginExecuteReader(cb, state);
return result;
}
catch (Exception ex)
{} …Run Code Online (Sandbox Code Playgroud) 为了使表单不可调整大小,我将MaximumSize和MinimumSize设置为相同的值.
我遇到的问题是,当用户指向窗体的边框时,鼠标指针会发生变化,使其看起来好像可以调整窗体大小.是不是可能发生这种情况?
是否有可能在xsl中实现"if else,if else"?例如,我有数据:
<document>
<line>
<name>MAR111</name>
<value>1</value>
</line>
<line>
<name>MAR111</name>
<value>3</value>
</line>
<line>
<name>MEA111</name>
<value>1</value>
</line>
<line>
<name>MPR111</name>
<value>1</value>
</line>
<line>
<name>MEA111</name>
<value>4</value>
</line>
<line>
<name>MPR111</name>
<value>2</value>
</line>
</document>
Run Code Online (Sandbox Code Playgroud)
我需要获得三个具有三个名称的文档模板:
<document>
<MAR>
<name>MAR111</name>
<number>1</number>
<number>4</number>
</MAR>
</document>
<document>
<MEA>
<name>MEA111</name>
<number>1</number>
<number>4</number>
</MEA>
</document>
<document>
<MPR>
<name>MPR111</name>
<number>1</number>
<number>2</number>
</MPR>
</document>
Run Code Online (Sandbox Code Playgroud)
我尝试在应用模板上使用"选择,何时",但也许有更好的方法:
<xsl:template match="/">
<xsl:choose>
<xsl:when test="/document/line/name='MEA111'">
<xsl:apply-templates mode="MEA" select="/document"/>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="/document/line/name='MPR111'">
<xsl:apply-templates mode="MPR" select="/document"/>
</xsl:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="/document/line/name='MAR111'">
<xsl:apply-templates mode="MAR" select="/document"/>
</xsl:when>
</xsl:choose>
</xsl:template>
Run Code Online (Sandbox Code Playgroud) 我正在为网站使用Paypal HTML API.Paypal似乎忽略了税收领域,反复支付.
这是一个错误吗?(我知道有一段时间了).有没有人设法在Paypal经常性付款中添加税收计算?
我正在努力提高我的MVC2应用程序启动的速度.
我做了第一轮性能抽样,看起来就是
MvcAreaRegistration.RegisterAllAreas
Run Code Online (Sandbox Code Playgroud)
占据了大部分的启动时间.
我在这里读到你也可以手动注册该区域,我想尝试一下,但我不确定该语法在该页面上是如何工作的.
所以我的(第一个)问题是:我如何手动注册我的区域?
我正在刷新我对Java并发性的记忆,我正在玩流行的生产者消费者问题.我已经实现了以下代码,如果有一个生产者和一个消费者,它可以正常工作.但是,如果有多个生产者/消费者,它将无法正常运行.我不明白为什么
public class ProducerConsumer {
static Monitor monitor;
public ProducerConsumer(int maxSize)
{
monitor = new Monitor(maxSize);
new Producer().start();
new Producer().start();
new Consumer().start();
new Consumer().start();
}
class Producer extends Thread{
@Override
public void run() {
while(true)
{
try {
monitor.insert();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
class Consumer extends Thread{
@Override
public void run() {
while(true)
{
try {
monitor.remove();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
class Monitor {
int n;
int maxSize; …Run Code Online (Sandbox Code Playgroud) 假设我定义了以下协议:
//用户界面对象的基本协议:
@protocol UIObjectProtocol <NSObject>
@property (assign) BOOL touchable;
@end
Run Code Online (Sandbox Code Playgroud)
//对象持有的用户界面对象的基本协议holder:
@protocol UIHeldObjectProtocol <UIObjectProtocol>
@property (readonly) id holder;
@end
Run Code Online (Sandbox Code Playgroud)
以下类层次结构:
//用户界面对象的基类,用于合成touchable属性
@interface UIObject : NSObject <UIObjectProtocol> {
BOOL _touchable;
}
@end
@implementation UIObject
@synthesize touchable=_touchable;
@end
Run Code Online (Sandbox Code Playgroud)
在这一点上,一切都很好.然后我创建一个UIObject名为的子类UIPlayingCard.本质上,UIPlayingCard符合UIObjectProtocol它,因为它的超类也是如此.
现在假设我想要UIPlayingCard遵守UIHeldObjectProtocol,所以我做了以下事情:
@interface UIPlayingCard : UIObject <UIHeldObjectProtocol> {
}
@end
@implementation UIPlayingCard
-(id)holder { return Nil; }
@end
Run Code Online (Sandbox Code Playgroud)
请注意,UIPlayingCard符合UIHeldObjectProtocol,传递符合UIObjectProtocol.但是我得到了编译器警告UIPlayingCard:
警告:属性'touchable'需要定义方法'-touchable' …
我通常使用IE条件并为每个条件都有一个样式表.这对我来说是一个更简洁的方法来做到这一点.但是由于某些限制,我必须在相同的样式表中破解ie6和7.
我知道它不会验证,但是如何在相同的样式表中使用hack隔离ie6和ie7?
我有一个PropertyGrid分配给它的一些对象.
var prpGrid = new PropertyGrid();
prp.SelectedObject = myObject;
Run Code Online (Sandbox Code Playgroud)
我想得到所有网格项,我可以得到selectedGridItem属性:
var selectedProperty = prpGrid.SelectedGridItem;
Run Code Online (Sandbox Code Playgroud)
我可以这样做吗?
c# ×3
concurrency ×2
java ×2
.net ×1
asp.net ×1
asp.net-mvc ×1
asynchronous ×1
css ×1
forms ×1
iphone ×1
objective-c ×1
paypal ×1
performance ×1
properties ×1
propertygrid ×1
protocols ×1
pthreads ×1
winforms ×1
xslt ×1