视图的加载过程有点慢,我想加入一个进度条,请问该如何操作?
DataGridView1.DataSource = myDataview这个加载过程有点慢,我想加入一个进度条,请问该如何操作? --------------------编程问答-------------------- 怎么没人回答呢?难道我的问题问得不好? --------------------编程问答-------------------- DataGridView1.DataSource = myDataview
加入一个进度条,可能需要记录总量,而且每获取一个记录需要刷新一次,不建议这样做;
建议加入一个loadingGIF;
具体多线程,MSDN里面好多。 --------------------编程问答-------------------- 请问这个多线程该如何使用啊? --------------------编程问答-------------------- Option Explicit On
Option Strict On
Imports System.Threading
' Our custom delegate.
Public Delegate Function BinaryOp(ByVal x As Integer, _
ByVal y As Integer) As Integer
Module Program
Sub Main()
Console.WriteLine("***** Async Delegate Invocation *****")
Console.WriteLine()
' Print out the ID of the executing thread.
Console.WriteLine("Main() invoked on thread {0}.", _
Thread.CurrentThread.ManagedThreadId)
' Invoke Add() on a secondary thread.
Dim b As BinaryOp = New BinaryOp(AddressOf Add)
Dim itfAR As IAsyncResult = b.BeginInvoke(10, 10, Nothing, Nothing)
While Not itfAR.AsyncWaitHandle.WaitOne(2000, True)
' Do other work on primary thread...
Console.WriteLine("Doing more work in Main()!")
Thread.Sleep(1000)
End While
' Obtain the result of the Add()
' method when ready.
Dim answer As Integer = b.EndInvoke(itfAR)
Console.WriteLine("10 + 10 is {0} .", answer)
Console.ReadLine()
End Sub
Function Add(ByVal x As Integer, ByVal y As Integer) As Integer
' Print out the ID of the executing thread.
Console.WriteLine("Add() invoked on thread {0}.", _
Thread.CurrentThread.ManagedThreadId)
' Pause to simulate a lengthy operation.
Thread.Sleep(5000)
Return x + y
End Function
End Module --------------------编程问答-------------------- 不太清楚 拜帖 學習一下 --------------------编程问答-------------------- 请问wl58796351前辈,您写的程序应该新建什么项目实现,好像不是用windows窗体控件实现的? --------------------编程问答-------------------- Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Dim a As Integer
Thread.Sleep(1000)
BackgroundWorker1.ReportProgress(a)
DataGridView1.DataSource = myDataview
End Sub
用backgroundworker来解决,在dowork过程中仍然提示:
Cross-thread operation not valid: Control 'DataGridView1' accessed from a thread other than the thread it was created on.
如果datagridview1被看成控件,对于dowork过程不能操作控件的要求,那岂不是用backgroundworker无法来解决些问题??????
补充:.NET技术 , VB.NET