由于C#使用垃圾收集.什么时候需要使用.Dispose释放内存?
我意识到有一些情况所以我会尝试列出我能想到的.
我正在为指定的Linux内核寻找POSIX实现函数的列表交叉引用矩阵.
例如,我想使用linux内核2.6.0,但我想看看这个内核的POSIX实现函数的compmlete列表.我在哪里可以找到这些信息?
我正在创建一个TCP连接的服务器.TCP连接在其自己的线程中运行无限长的时间.是否有一个好的模式允许安全关闭TcpListener和客户端以及线程?以下是我到目前为止的情况.
private volatile bool Shudown;
void ThreadStart1()
{
TcpListener listener = null;
TcpClient client = null;
Stream s = null;
try
{
listener = new TcpListener(60000);
client = listener.AcceptTcpClient();
Stream s = client.GetStrea();
while(!Shutdown) // use shutdown to gracefully shutdown thread.
{
try
{
string msg = s.ReadLine(); // This blocks the thread so setting shutdown = true will never occur unless a client sends a message.
DoSomething(msg);
}
catch(IOException ex){ } // I would like to avoid using Exceptions …Run Code Online (Sandbox Code Playgroud) 我正在尝试将Usercontrol添加到表单中.UserControl与表单位于一个单独的项目中,但是在同一个解决方案中.我已将此控件添加到过去的其他表单中,但是,某些内容已更改,我收到以下错误:
"无法创建组件
MessageDisplayListControl.错误消息如下:'System.Runtime.Serialization.SerializationException:在Assymbly AceXtremeNET中键入AceXtremeNET.Utilities.Message',版本= 10.0.0.273,......未标记为可序列化.在System.Runtime.Serialization.FormatterServices.InternalGetSerializableMember(RuntimeType type)at ...."
控件确实已添加到.Designer.cs,但是,它不会显示在可视GUI中.每当我尝试构建时,我会得到多个错误,这些错误会产生与上面相同的基本错误,即'AceXtremeNET.Utilities.Message'不是Serializable.
---------编辑------------------
我的控件具有以下属性,似乎问题.
public IList<Message> MessageList {get{return _getList();} {set {_lostList(value);}}
Run Code Online (Sandbox Code Playgroud)
控件中的代码不依赖于此属性,因为它意味着purley作为get/set访问器.每当我注释掉代码时,Everything似乎都能正常工作.否则我可以上面提到的错误.我之前提到过,我收到了另一个关于构建的错误,看起来这是唯一尝试序列化的Property.
---------编辑(堆栈跟踪)------------------
at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type)
at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context)
at System.Runtime.Serialzation.Formatters.Binary.WriteObjectInfo.InitMemberInfo()
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Type objectType, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, SerializationBinder binder)
at System.Runtime.SerializationFormatters.Binary.ObjectWriter.WriteArray(WriteObjectInfo objectInfo, NameInfo memberNameInfo, WriteObjectInfo memberObjectInfo)
...
Run Code Online (Sandbox Code Playgroud)
---------编辑(控制属性)------------------
public MessageControl MessageDisplay {get{return messageControl1;}} // This is another user control I created. I've not had any problems with this control.
public MessageListBox {get { return …Run Code Online (Sandbox Code Playgroud) 我需要一个函数在+/- 1ms内的精确时间运行.我尝试过以下操作但最终执行时间最短为15毫秒.
void Main()
{
System.Timers.Timer timer = new System.Timers.Timer(1); // executes every 15ms
timer.Elapsed += new System.Timers.ElapsedEventHandler(myFunction);
System.Timers.Timer timer2 = new System.Timers.Timer(5); // executes every 15ms
timer2.Elapsed += new System.Timers.ElapsedEventHandler(myFunction);
System.Timers.Timer timer2 = new System.Timers.Timer(20); // executes every 31ms
timer3.Elapsed += new System.Timers.ElapsedEventHandler(myFunction);
timer.Start();
timer2.Start();
timer3.Start();
}
void myFunction()
{
doWord();
}
Run Code Online (Sandbox Code Playgroud)
使用Thread.Sleep()获得相同的结果.
申请概要.
我将在一个包含1553条消息的文件中读取(每条消息都有一个时间戳).我需要尽可能接近文件所包含的时间重播这些消息.消息的时间戳记录在microsec中,但我只需要msec准确度.
这是使用DDC 1553卡(PCI卡)完成的.我有一个分析器,它允许我查看消息,包括消息之间的增量时间,以测量我的准确性.
我正在使用的机器有一个具有超线程的QuadCore.使用for(int i = 0; .....)我可以获得0.5毫秒的准确度.然而,这是非常低效的,并且如果可能的话,更愿意使用更现实且更便携的方法.
.net ×4
c# ×4
linux ×1
linux-kernel ×1
memory-leaks ×1
performance ×1
posix ×1
timer ×1
winforms ×1