我使用下面的代码启动带有列表参数的线程,但有时它会引发异常:
给定的密钥不在字典中
从这一行:
Thread MoveThread = new Thread(() => MoveTask(ControllerDictionary[i]));
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个错误?
完整代码:
var ControllerDictionary = ConfigFile.ControllerList.Select((c, i) => new { Controller = c, Index = i })
.GroupBy(x => x.Index % AppSettings.SimultaneousProcessNumber)
.Select((g, i) => new { GroupIndex = i, Group = g })
.ToDictionary(x => x.GroupIndex, x => x.Group.Select(xx => xx.Controller).ToList());
for (int i = 0; i < ControllerDictionary.Count; i++)
{
Thread MoveThread = new Thread(() => MoveTask(ControllerDictionary[i]));
MoveThread.Start();
foreach (var Controller in ControllerDictionary[i])
Logger.Write(string.Format("{0} is in move thread …Run Code Online (Sandbox Code Playgroud) 你好我有一个JavaScript代码,我想在ASP文件中使用它,但我的错误代码说:
Active Server Pages错误'ASP 0138'
嵌套脚本块
/reklamsag.html,第3行
脚本块不能放在另一个脚本块中.
我的代码是:
<script src="http://ad.reklamport.com/scripts/rp.js" type="text/javascript"></script>
<script type="text/javascript">
document.write("<script src='http://ad.reklamport.com/rpgetad.ashx?tt=t_canvecan_anasayfa_300x250&ciid=&rnd="+Math.random()%99999999+"'></"+"script>");
</script>
Run Code Online (Sandbox Code Playgroud)
有人说在外部文件中使用代码并将其包含在asp文件中我使用此包含代码,但它不起作用:
<!--#include file="reklamsag.html"-->
Run Code Online (Sandbox Code Playgroud) 我有一个字符串AssetNumber具有以下格式C100200.所以我需要做的是: -
获取第一个之后的所有字符(例如,使用上面的例子100200)
将子字符串转换为整数
返回整数+ 1
但我不知道如何使用子字符串获取第一个字符后的所有字符,以及如何将字符串转换为int?任何有关这方面的帮助将不胜感激.
我在旧的IIS机器上使用以下代码为我为android和ios设备构建的移动应用程序生成XML ...它可以工作,但我现在想要弄清楚我将如何按照日期最后一次修改进行SORTING列表顶部有最新的文件...我的问题是,根据我在下面编写代码的方式,
这可能与我现有的代码(以某种方式排序'x'?)?
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%Response.ContentType = "text/xml"%>
<%Response.AddHeader "Content-Type","text/xml"%>
<songlist>
<%
dim fs,fo,x
dim i
set fs=Server.CreateObject("Scripting.FileSystemObject")
'point to a specific folder on the server to get files listing from...
set fo=fs.GetFolder(Server.MapPath("./songs"))
i = -1
for each x in fo.files
'loop through all the files found, use var 'i' as a counter for each...
i = i + 1
'only get files where the extension is 'mp3' -- we only want the mp3 files to show in list...
if …Run Code Online (Sandbox Code Playgroud) 我现在面临一个问题,我现在正在实习,我必须修改一个给定的程序.我有一些滞后问题,我终于找到了问题:日志编写器......
程序运行的越多,它就越慢,实际上就越慢.我发现这是因为日志文件的编写器,这里是代码:
using (StreamWriter swLog = new StreamWriter(GenerateDaylog(_logPath), true))
{
String sLog = "";
sLog += DateTime.Now.ToShortDateString();
sLog += " ";
sLog += DateTime.Now.ToLongTimeString();
sLog += "\t";
sLog += new StackFrame(1).GetMethod().DeclaringType.Name;
sLog += "\t";
sLog += new StackFrame(1).GetMethod().Name;
sLog += "\t";
sLog += msg;
Trace.Listeners.Add(new TextWriterTraceListener(swLog));
Trace.WriteLine(sLog);
}
Run Code Online (Sandbox Code Playgroud)
现在,日志文件大约为100 - 500 ko,每天都会创建一个新日志文件,并在其名称中包含日期.
我想这个写行者有问题,但我无法弄清楚它是什么.
我读了c#程序编译需要两个步骤.
首先它生成MSIL然后生成机器代码.所以我很想看到第一阶段编译(MSIL)生成的文件.
我一直在想DLL文件是包含MSIL代码的文件,但我认为我错了.
我试图实现插入语句并使用我的函数在页面加载中返回.不知道我怎么能插入同时绘制我插入到mysql中的所有内容一次又一次出来?
码:
public partial class UserProfileWall : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string theUserId = Session["UserID"].ToString();
using (OdbcConnection cn = new OdbcConnection("Driver={MySQL ODBC 3.51 Driver}; Server=localhost; Database=gymwebsite2; User=user_name; Password=password_here;"))
{
cn.Open();
using (OdbcCommand cmd = new OdbcCommand("SELECT Wallpostings FROM WallPosting WHERE UserID=" + theUserId + " ORDER BY idWallPosting DESC", cn))
using (OdbcDataReader reader = cmd.ExecuteReader())
{
var divHtml = new System.Text.StringBuilder();
while (reader.Read())
{
divHtml.Append("<div id=test>");
divHtml.Append(String.Format("{0}", reader.GetString(0)));
divHtml.Append("</div>");
}
test1.InnerHtml = divHtml.ToString();
}
} …Run Code Online (Sandbox Code Playgroud) 我有5个项目的下拉列表.
我想将所选项目发送到下一个jsp页面.
JavaScript代码:
var display= document.getElementById('displayId');
var j;
var count =0;
for(j=0;j< display.options.length;j++){
if(display.options[j].selected){
displaySelected = display.options[j].value;
count++;
}
}
alert(displaySelected);
Run Code Online (Sandbox Code Playgroud)
HTML代码:
<SELECT NAME="displayId" id="displayId" style="width:300px;">
<option>Host</option>
<option>Host And Response Time</option>
<option>Host And User Count</option>
<option>User Count And Reponse Time</option>
<option>Host,UserCount And Response Time</option>
</SELECT>
Run Code Online (Sandbox Code Playgroud)
这适用于Fire fox,但不适用于IE ...任何人都可以找到错误吗?
我希望使用C#链接列表类而不是创建我自己的,但我不知道如何粘贴多个项目LinkedList<>.
我想做点什么LinkedList<string, List>,让我有:
entry1->string
还有一个清单:
entry2->string, and list
我从教程中看到的所有内容都只允许LinkedList,
关于如何在链表中获得超过1个值的任何想法?谢谢.
我有代码:
function (i)
{
alert(i);
}(3);
Run Code Online (Sandbox Code Playgroud)
我不明白为什么我没有看到警报.
这个语法是什么意思?
为什么这段代码:
( function (i)
{
alert(i);
}(3))();
Run Code Online (Sandbox Code Playgroud)
有用吗?
有什么不同?
我想念的是什么?
c# ×6
javascript ×3
asp-classic ×2
.net ×1
asp.net ×1
cil ×1
dictionary ×1
html ×1
mysql ×1
performance ×1
sql ×1
streamwriter ×1