在我这一行的程序中:
int value = MTEConnect(auth_string, err);
Run Code Online (Sandbox Code Playgroud)
我收到这样的例外:
FatalExecutionEngineError
The runtime has encountered a fatal error. The address of the
error was at 0x68c8a681, on thread 0x2334. The error code is
0xc0000005. This error may be a bug in the CLR or in the unsafe
or non-verifiable portions of user code. Common sources of this
bug include user marshaling errors for COM-interop or PInvoke,
which may corrupt the stack.
Run Code Online (Sandbox Code Playgroud)
MTEConnect 是这样导入的:
[DllImport("mtesrl.dll", CharSet = CharSet.Ansi)]
private static extern int MTEConnect(String pars, …Run Code Online (Sandbox Code Playgroud) 我的xsl有一个参数
<xsl:param name="halfPath" select="'halfPath'"/>
Run Code Online (Sandbox Code Playgroud)
我想在比赛中使用它
<xsl:template match="Element[@at1='value1' and not(@at2='{$halfPath}/another/half/of/the/path')]"/>
Run Code Online (Sandbox Code Playgroud)
但这不起作用.我想一个不能在''里面使用参数.如何修复/解决这个问题?
我需要在我的软件中记录大量信息以进行调试.但是我只在开发期间需要这个选项,我宁愿在Release中排除所有这些代码.
当然我可以用"if"包围我想调试的地方:
if (isDebugMode()) {
Logger.log(blahblah);
}
Run Code Online (Sandbox Code Playgroud)
但是因为我的软件对时间要求很高,所以我想避免大量的unnesseray"if"测试.
即我认为我需要模拟c"#define #ifdef #ifndef".c#或.net中是否有任何技术可以轻松解决我的任务?
我想在JTable中灰化不可编辑的单元格.我正在使用这样的TableCellRenderer:
TableColumn column = table.getColumnModel().getColumn(0);
column.setCellRenderer(new GrayableCheckboxCellRenderer());
public class GrayableCheckboxCellRenderer extends JCheckBox implements TableCellRenderer {
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int vRowIndex, int vColIndex) {
boolean editable = isEditable(vRowIndex, vColIndex);
setBackground(editable ? UIManager.getColor("Label.background") : Color.LIGHT_GRAY);
setSelected((Boolean) value);
if (isSelected) {
// TODO: cell (and perhaps other cells) are selected, need to highlight it
}
return this;
}
// perfomance
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {}
public void firePropertyChange(String propertyName, boolean oldValue, boolean …Run Code Online (Sandbox Code Playgroud) 我想实现我的第一个WCF回叫服务器.这是我的代码:
[ServiceContract(SessionMode = SessionMode.Required, CallbackContract = typeof(ILogCallback))]
public interface ILog
{
}
public interface ILogCallback
{
[OperationContract(IsOneWay = true)]
void Push(string callbackValue);
}
public class MyLog : ILog
{
}
class Log
{
public static void initialize()
{
using (ServiceHost host = new ServiceHost(
typeof (MyLog),
new Uri[]
{
new Uri("net.pipe://localhost")
}))
{
host.AddServiceEndpoint(typeof (ILog),
new NetNamedPipeBinding(),
"PipeReverse");
host.Open();
// TODO: host.Close();
}
}
public static void Push(string s)
{
ILogCallback callbacks = OperationContext.Current.GetCallbackChannel<ILogCallback>();
callbacks.Push(s);
}
}
Run Code Online (Sandbox Code Playgroud)
然后我尝试使用此代码使用我的服务器:
Log.initialize();
while …Run Code Online (Sandbox Code Playgroud) 我希望在单击DataGrid项时在我的ViewModel中执行一个命令.作为参数,我希望有相应的行.
我在互联网上找到了一种方法,但它使用了 DependencyProperty
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/632ea875-a5b8-4d47-85b3-b30f28e0b827
我没有DependencyProperty在我的项目中使用,而是我正在使用INotifyPropertyChanged.如何实现"双击数据网格"commaind而不使用DependencyProperty?
我需要将double值四舍五入为2位数.什么是可取的?
String.Format("{0:0.00}", 123.4567); // "123.46"
Math.Round(123.4567, 2) // "123.46"
Run Code Online (Sandbox Code Playgroud) 根据msdn DateTime,精度为10毫秒.因此t2-t1,下面示例中的精度也是10 ms.但是返回的值是"双倍",令人困惑.
DateTime t1 = DateTime.Now; // precision is 10 ms
....
DateTime t2 = DateTime.Now; // precision is 10 ms
... (t2-t1).TotalMilliseconds; // double (so precision is less than 1 ms???)
Run Code Online (Sandbox Code Playgroud)
我期望int值,因为当精度为10 ms时,double值没有意义.我需要在Thread.Sleep()中使用结果值.我应该转换为int吗?
队列中含有特殊的方法queue.Peek(),我为什么要使用它时,我可以使用一般的queue.First()和queue.Last()?
我有一个线程,我需要每隔10毫秒做一些事情.所以我有非常简单的代码,像那样:
while (work) {
// do something
Sleep(10000); // boost sleep can be also used
}
Run Code Online (Sandbox Code Playgroud)
我听说Sleep一般不推荐这样做,如果我用deadline_timer整体应用程序性能替代它会更好,特别是我会避免昂贵的"上下文切换".
我应该改变sleep,以deadline_timer若然有人可以举个例子?