小编Jim*_*ell的帖子

C#应用程序变得缓慢且无法响应,因为多行文本框中的字符串增长

我有一个C#应用程序,其中有很多信息被添加到文本框中以显示给用户.在处理数据时,几乎立即,应用程序变得非常缓慢且无响应.这就是我目前正在尝试处理这个问题的方法:

   var saLines = textBox1.Lines;
   var saNewLines = saLines.Skip(50);
   textBox1.Lines = saNewLines.ToArray();
Run Code Online (Sandbox Code Playgroud)

此代码每100mS从一个计时器运行.有没有更好的方法来处理这个?我使用的是Microsoft Visual C#2008 Express Edition.谢谢.

c# performance textbox timer

2
推荐指数
1
解决办法
2927
查看次数

如何填写C#comboBox中的空格作为用户的提示?

当动态填充C#中的comboBox时,comboBox将显示为空白,直到用户单击它以查看下拉列表中的可用项目为止.理想情况下,我想使用此空白区域(在单击下拉列表之前)用于向用户提供有关他/她应该做什么的提示.例如,它可能会说"选择这样的......"有没有办法做到这一点?我尝试设置Text属性,但是没有做任何事情.我使用的是Microsoft Visual C#2008 Express Edition.谢谢.

c# combobox

2
推荐指数
2
解决办法
4149
查看次数

来自C#中BackgroundWorker2_RunWorkerCompleted的无效跨线程操作

我收到一个没有意义的错误.

Cross-thread operation not valid: Control 'buttonOpenFile' accessed from a thread other than the thread it was created on.

在我的应用程序中,UI线程会触发backgroundWorker1,当几乎完成时会触发backgroundWorker2并等待它完成. backgroundWorker1backgroundWorker2完成之前等待完成. AutoResetEvent变量用于标记每个工作人员何时完成.在backgroundWorker2_RunWorkerComplete调用函数中,重置表单控件.在此ResetFormControls()函数中抛出异常.我认为修改RunWorkerCompleted函数中的表单控件是安全的.两个后台工作程序都是从UI线程实例化的.这是我正在做的一个非常概括的版本:

  AutoResetEvent evtProgrammingComplete_c = new AutoResetEvent(false);
  AutoResetEvent evtResetComplete_c = new AutoResetEvent(false);

  private void ResetFormControls()
  {
     toolStripProgressBar1.Enabled = false;
     toolStripProgressBar1.RightToLeftLayout = false;
     toolStripProgressBar1.Value = 0;

     buttonInit.Enabled = true;
     buttonOpenFile.Enabled = true; // Error occurs here.
     buttonProgram.Enabled = true;
     buttonAbort.Enabled = false;
     buttonReset.Enabled = true;
     checkBoxPeripheryModule.Enabled = …
Run Code Online (Sandbox Code Playgroud)

c# multithreading backgroundworker concurrent-processing

2
推荐指数
1
解决办法
935
查看次数

敏捷和以体系结构为中心的软件开发有什么区别?

从我所读到的,"敏捷"似乎只是一个用于黑客攻击和斜线开发的委婉术语.换句话说,在以架构为中心的开发基于设计文档的情况下,敏捷开发本身没有"设计",并且代码只是被攻击,直到它通过测试.我真的希望事实并非如此.澄清将非常感激.谢谢.

architecture agile

2
推荐指数
1
解决办法
1061
查看次数

将HLOCAL转换为LPTSTR

如何将HLOCAL数据类型转换为LPTSTR数据类型?我正在尝试从Microsoft工作中获取代码片段,这是唯一的错误,我不确定如何解决:

// Create a HDEVINFO with all present devices.
hDevInfo = SetupDiGetClassDevs(NULL,
    0, // Enumerator
    0,
    DIGCF_PRESENT | DIGCF_ALLCLASSES );

if (hDevInfo == INVALID_HANDLE_VALUE)
{
    // Insert error handling here.
    return NULL;
}

// Enumerate through all devices in Set.

DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
for (i=0;SetupDiEnumDeviceInfo(hDevInfo, i, &DeviceInfoData);i++)
{
    DWORD DataT;
    LPTSTR buffer = NULL;
    DWORD buffersize = 0;

    //
    // Call function with null to begin with, 
    // then use the returned buffer size (doubled)
    // …
Run Code Online (Sandbox Code Playgroud)

c++ winapi

2
推荐指数
1
解决办法
2379
查看次数

如何组合html表单

我如何组合 2 个 html 表单

我正在尝试组合不同位置的表格。这样我就可以一次性发布所有数据。

这是一个例如

<form action="actions.php">
<input type="text">
<input type="text">
 <input type="submit" name="button" id="button" value="submit" />

</form> 


<form>
<input type="text">
<input type="text">
 </form> 
Run Code Online (Sandbox Code Playgroud)

html forms page-layout

2
推荐指数
1
解决办法
2万
查看次数

使用RegisterClassEx的问题

在我的Win32 C++ DLL中,我发现如果我尝试使用RegisterClassEx这种方式它可以正常工作:

WNDCLASSEX wx = {};
wx.cbSize = sizeof(WNDCLASSEX);
wx.lpfnWndProc = (WNDPROC)WndProc;        // function which will handle messages
wx.hInstance = GetCurrentModule();
wx.lpszClassName = pClassName;
atomRet = RegisterClassEx( &wx );
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试使用RegisterClassEx这种方式时,它会失败,atomRet设置为零,并且异常文本只是说"参数不正确".

WNDCLASSEX * _pWndClassEx;
_pWndClassEx = (WNDCLASSEX *)malloc( sizeof(WNDCLASSEX) );
_pWndClassEx->cbSize = sizeof(WNDCLASSEX);
_pWndClassEx->lpfnWndProc = (WNDPROC)WndProc;        // function which will handle messages
_pWndClassEx->hInstance = GetCurrentModule();
_pWndClassEx->lpszClassName = pClassName;
atomRet = RegisterClassEx( _pWndClassEx );
Run Code Online (Sandbox Code Playgroud)

我在MSDN文档中RegisterClassEx注意到它的定义如下:

ATOM WINAPI RegisterClassEx(
  __in  const WNDCLASSEX *lpwcx
); …
Run Code Online (Sandbox Code Playgroud)

c++ winapi visual-studio-2008

2
推荐指数
1
解决办法
1107
查看次数

计算PWM的频率

这应该是一个简单的公式,但我无法弄清楚.

我有一个16mHZ的AVR芯片.

我需要运行一个PWM信号为24kHZ ..

什么是决定什么是最好的预分频器的公式.

我使用的是16位定时器.

c embedded math avr discrete-mathematics

2
推荐指数
1
解决办法
3366
查看次数

MySQL INSERT 错误操作数应包含 1 列

我有这个 MySQL 插入查询,它给了我一个Error Code: 1241. Operand should contain 1 column(s).

INSERT INTO esjp_content
    ( esjp_content.primary_key, esjp_content.template_id, esjp_content.section_ref,
    esjp_content.position, esjp_content.indent, esjp_content.content,
    esjp_content.summary_id, esjp_content.role_ref, esjp_content.author_id,
    esjp_content.event_id, esjp_content.sys_time )
VALUES
    ( ( 3, 1, 1, 0, 0, 'Some test content.', 0, 1, 1, 69, UNIX_TIMESTAMP(NOW()) ),
    ( 4, 1, 1, 1, 1, 'Some test content2.', 0, 1, 1, 69, UNIX_TIMESTAMP(NOW()) ) )
ON DUPLICATE KEY UPDATE
    esjp_content.primary_key=VALUES(esjp_content.primary_key),
    esjp_content.template_id=VALUES(esjp_content.template_id),
    esjp_content.section_ref=VALUES(esjp_content.section_ref),
    esjp_content.position=VALUES(esjp_content.position),
    esjp_content.indent=VALUES(esjp_content.indent),
    esjp_content.content=VALUES(esjp_content.content),
    esjp_content.summary_id=VALUES(esjp_content.summary_id),
    esjp_content.role_ref=VALUES(esjp_content.role_ref),
    esjp_content.author_id=VALUES(esjp_content.author_id),
    esjp_content.event_id=VALUES(esjp_content.event_id),
    esjp_content.sys_time=VALUES(esjp_content.sys_time);
Run Code Online (Sandbox Code Playgroud)

它工作正常,如果我一次只尝试插入 1 条记录,但我认为这INSERT …

mysql insert mysql-error-1241

2
推荐指数
1
解决办法
8753
查看次数

如何从构造函数中确定类的内存分配地址?

是否有可能从该类的构造函数中获取新实例化的类的内存分配地址?
我正在开发一个链表,其中多个类有多个指向类的指针.每次新类实例化时,都需要检查其父级列表以确保它包含在内.

如果我尝试做这样的事情:

MyClass() // constructor
{
   extern MyClass * pParent;

   for ( int i = 0; i < max; i++ )
   {
      pParent->rels[i] == &MyClass; // error
   }
}
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

错误C2275:'namespace :: MyClass':非法使用此类型作为表达式

任何想法或建议将不胜感激.谢谢.

c++ class instantiation

1
推荐指数
2
解决办法
130
查看次数