我想线程将是克服你的问题的概念。您可以做的是在表单加载时启动一个新线程。让线程完成组合框填充或您需要的任何工作。
该线程将异步更新所有组合框。所以表单加载时不会有延迟。下面提供了线程的简短示例。我想这会帮助你百分之一!
public class MyClass
{
private volatile bool _KillThread;
// This method will be called when the thread is started.
public void DoWork()
{
while (!_KillThread)
{
//Do your work
}
}
public void RequestStop()
{
_KillThread= true;
}
}
static void MyFunction()
{
MyClassworkerObject = new MyClass();
Thread workerThread = new Thread(workerObject.DoWork);
// Start the thread.
workerThread.Start();
while (!workerThread.IsAlive);
// allow the worker thread to do some work:
Thread.Sleep(1);
// Request that the worker thread stop itself:
workerObject.RequestStop();
//Wait untill the worker thread joins it self to main thread
workerThread.Join();
}
您会在 MSDN 上找到类似的示例,因为我在一年前在我的应用程序中实现它时已经从那里引用了代码。
干杯!!