111,119
社区成员
发帖
与我相关
我的任务
分享 private void bwLoadBlog_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (e.Error != null)
{
MessageBox.Show(e.Error.Message);
}
else if (e.Cancelled)
{
lblStatus.Text = "已取消";
}
else
{
panel.Visible = false;
int len = listTitle.Count;
dataGridView.RowCount = len;
for (int i = 0; i < len; i++)
{
dataGridView.Rows[i].Cells["Title"].Value = listTitle[i];
}
lblStatus.Text = e.Result.ToString();
}
}
private delegate void AsyncWork(DataTable dt,string str);
private AsyncWork work;
private void UpdatePanel(DataTable dt,string status)
{
int len=dt.Rows.Count;
dataGridView.RowCount = len;
for (int i = 0; i < len; i++)
{
dataGridView.Rows[i].Cells["Title"].Value = listTitle[i];
}
lblStatus.Text = status;
}
private void bwLoadBlog_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (e.Error != null)
{
MessageBox.Show(e.Error.Message);
}
else if (e.Cancelled)
{
lblStatus.Text = "已取消";
}
else
{
panel.Visible = false;
int len = listTitle.Count;
DataTable dt = new DataTable();
dt.Columns.Add("Title", Type.GetType("System.String"));
for (int i = 0; i < len; i++)
{
DataRow dr = dt.NewRow();
dr["Title"] = listTitle[i];
dt.Rows.Add(dr);
}
AsyncWork work = new AsyncWork(UpdatePanel);
work(dt, e.Result.ToString());
}
}
//dataGridView.RowCount = len;
for (int i = 0; i < len; i++)
{
// dataGridView.Rows[i].Cells["Title"].Value = listTitle[i];
}
// lblStatus.Text = status;
在 System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
在 System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
在 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
在 System.Delegate.DynamicInvokeImpl(Object[] args)
在 System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
在 System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
在 System.Threading.ExecutionContext.runTryCode(Object userData)
在 System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
在 System.Windows.Forms.Control.InvokeMarshaledCallbacks()
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 BlogExporter.Program.Main() 位置 E:\\BlogExporter\Program.cs:行号 18
在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormMain());//这里报错
}