本文整理汇总了C#中System.ComponentModel.BackgroundWorker.ReportProgress方法的典型用法代码示例。如果您正苦于以下问题:C# System.ComponentModel.BackgroundWorker.ReportProgress方法的具体用法?C# System.ComponentModel.BackgroundWorker.ReportProgress怎么用?C# System.ComponentModel.BackgroundWorker.ReportProgress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ComponentModel.BackgroundWorker
的用法示例。
在下文中一共展示了System.ComponentModel.BackgroundWorker.ReportProgress方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Program_Click
//.........这里部分代码省略.........
catch
{
System.Windows.Forms.SaveFileDialog sd = new System.Windows.Forms.SaveFileDialog();
sd.Title = "另存新檔";
sd.FileName = reportName + ".doc";
sd.Filter = "Excel檔案 (*.doc)|*.doc|所有檔案 (*.*)|*.*";
if (sd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
try
{
document.Save(sd.FileName, Aspose.Words.SaveFormat.Doc);
}
catch
{
FISCA.Presentation.Controls.MsgBox.Show("指定路徑無法存取。", "建立檔案失敗", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
return;
}
}
}
#endregion
FISCA.Presentation.MotherForm.SetStatusBarMessage("班級評量成績單產生完成。", 100);
if (overflowRecords.Count > 0)
MessageBox.Show(err);
};
bkw.DoWork += delegate(object sender, System.ComponentModel.DoWorkEventArgs e)
{
#region 偷跑取得考試成績
Dictionary<string, Dictionary<string, Dictionary<string, ExamScoreInfo>>> studentExamSores = new Dictionary<string, Dictionary<string, Dictionary<string, ExamScoreInfo>>>();
Dictionary<string, Dictionary<string, ExamScoreInfo>> studentRefExamSores = new Dictionary<string, Dictionary<string, ExamScoreInfo>>();
ManualResetEvent scoreReady = new ManualResetEvent(false);
ManualResetEvent elseReady = new ManualResetEvent(false);
bkw.ReportProgress(3);
new Thread(new ThreadStart(delegate
{
// 取得學生學期科目成績
int sSchoolYear, sSemester;
int.TryParse(conf.SchoolYear, out sSchoolYear);
int.TryParse(conf.Semester, out sSemester);
#region 整理學生定期評量成績
#region 篩選課程學年度、學期、科目取得有可能有需要的資料
List<CourseRecord> targetCourseList = new List<CourseRecord>();
try
{
foreach (var courseRecord in accessHelper.CourseHelper.GetAllCourse(sSchoolYear, sSemester))
{
//用科目濾出可能有用到的課程
if (conf.PrintSubjectList.Contains(courseRecord.Subject)
|| conf.TagRank1SubjectList.Contains(courseRecord.Subject)
|| conf.TagRank2SubjectList.Contains(courseRecord.Subject))
targetCourseList.Add(courseRecord);
}
}
catch (Exception exception)
{
exc = exception;
}
#endregion
try
{
if (conf.ExamRecord != null || conf.RefenceExamRecord != null)
{
accessHelper.CourseHelper.FillExam(targetCourseList);
var tcList = new List<CourseRecord>();
var totalList = new List<CourseRecord>();
示例2: AddMenuButton
public static void AddMenuButton()
{
var ribbonBarItem = K12.Presentation.NLDPanels.Course.RibbonBarItems["課程行事曆"];
Catalog button_syncCalendar = RoleAclSource.Instance["課程"]["功能按鈕"];
button_syncCalendar.Add(new RibbonFeature("Reset_Course_Calendar", "重置課程行事曆"));
bool isEnabled = UserAcl.Current["Reset_Course_Calendar"].Executable;
var btn = ribbonBarItem["重置課程行事曆"];
if (isEnabled)
{
ribbonBarItem["重置課程行事曆"].Click += delegate
{
if (System.Windows.Forms.MessageBox.Show("將會清空行事例曆中所有資料,\n以及系統內課程同步狀態。\n\nPS.不會影響輸入的上課時間資料。", "重置課程行事曆", System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK)
{
System.ComponentModel.BackgroundWorker bkw = new System.ComponentModel.BackgroundWorker();
bkw.WorkerReportsProgress = true;
bkw.RunWorkerCompleted += delegate
{
FISCA.Presentation.MotherForm.SetStatusBarMessage("重置課程行事曆完成。", 100);
System.Windows.Forms.MessageBox.Show("課程行事曆已重置,\n請上google calendar檢查,\n如有殘留資料請再執行此功能。");
};
bkw.ProgressChanged += delegate(object sender, System.ComponentModel.ProgressChangedEventArgs e)
{
FISCA.Presentation.MotherForm.SetStatusBarMessage("重置課程行事曆...", e.ProgressPercentage);
};
bkw.DoWork += delegate
{
bkw.ReportProgress(1);
var accessHelper = new FISCA.UDT.AccessHelper();
var l1 = accessHelper.Select<Section>();
foreach (Section section in l1)
{
section.IsPublished = false;
}
l1.SaveAll();
bkw.ReportProgress(5);
var l2 = accessHelper.Select<Calendar>();
foreach (Calendar cal in l2)
{
cal.Deleted = true;
}
l2.SaveAll();
bkw.ReportProgress(10);
#region 清空行事曆
CalendarService myService = new CalendarService("ischool.CourseCalendar");
myService.setUserCredentials(googleAcc, googlePWD);
CalendarQuery cq = new CalendarQuery();
cq.Uri = new Uri("http://www.google.com/calendar/feeds/default/owncalendars/full");
CalendarFeed resultFeed = myService.Query(cq);
foreach (CalendarEntry entry in resultFeed.Entries)
{
String calendarURI = entry.Id.Uri.ToString();
String calendarID = calendarURI.Substring(calendarURI.LastIndexOf("/") + 1);
clearAndDeleteCalender(calendarID);
}
bkw.ReportProgress(55);
deleteAllEvent("default");
#endregion
bkw.ReportProgress(100);
};
bkw.RunWorkerAsync();
}
};
}
else
{
btn.Enable = false;
}
}
示例3: Program_Click
//.........这里部分代码省略.........
#endregion
}
}
}
catch (Exception exception)
{
exc = exception;
}
finally
{
scoreReady.Set();
}
#endregion
#region 整理學生學期、學年成績
try
{
accessHelper.StudentHelper.FillAttendance(studentRecords);
accessHelper.StudentHelper.FillReward(studentRecords);
}
catch (Exception exception)
{
exc = exception;
}
finally
{
elseReady.Set();
}
#endregion
})).Start();
#endregion
try
{
string key = "";
bkw.ReportProgress(0);
#region 缺曠對照表
List<K12.Data.PeriodMappingInfo> periodMappingInfos = K12.Data.PeriodMapping.SelectAll();
Dictionary<string, string> dicPeriodMappingType = new Dictionary<string, string>();
List<string> periodTypes = new List<string>();
foreach (K12.Data.PeriodMappingInfo periodMappingInfo in periodMappingInfos)
{
if (!dicPeriodMappingType.ContainsKey(periodMappingInfo.Name))
dicPeriodMappingType.Add(periodMappingInfo.Name, periodMappingInfo.Type);
if (!periodTypes.Contains(periodMappingInfo.Type))
periodTypes.Add(periodMappingInfo.Type);
}
foreach (var absence in K12.Data.AbsenceMapping.SelectAll())
{
foreach (var pt in periodTypes)
{
string attendanceKey = pt + "_" + absence.Name;
if (!table.Columns.Contains(attendanceKey))
{
table.Columns.Add(attendanceKey);
}
}
}
#endregion
bkw.ReportProgress(3);
#region 整理學生住址
accessHelper.StudentHelper.FillContactInfo(studentRecords);
#endregion
#region 整理學生父母及監護人
accessHelper.StudentHelper.FillParentInfo(studentRecords);
#endregion
bkw.ReportProgress(10);
示例4: Program_Click
//.........这里部分代码省略.........
}
}
}
//學期學業成績校排名
if ("" + dr["year_rating"] != "")
{
doc.LoadXml("" + dr["year_rating"]);
foreach (System.Xml.XmlElement ele in doc.SelectNodes("Rating/Item"))
{
//<Item 分項="學業" 成績="90.6" 成績人數="35" 排名="2"/>
rec.Fields.Add("學期科目校排名" + ele.GetAttribute("科目") + "^^^" + ele.GetAttribute("科目級別"), ele.GetAttribute("排名"));
rec.Fields.Add("學期科目校排名母數" + ele.GetAttribute("科目") + "^^^" + ele.GetAttribute("科目級別"), ele.GetAttribute("成績人數"));
}
}
}
#endregion
accessHelper.StudentHelper.FillAttendance(studentRecords);
accessHelper.StudentHelper.FillReward(studentRecords);
}
catch (Exception exception)
{
exc = exception;
}
finally
{
elseReady.Set();
}
#endregion
})).Start();
#endregion
try
{
string key = "";
bkw.ReportProgress(0);
#region 日常行為表現資料表
SmartSchool.Customization.Data.SystemInformation.getField("文字評量對照表");
foreach (System.Xml.XmlElement ele in (SmartSchool.Customization.Data.SystemInformation.Fields["文字評量對照表"] as System.Xml.XmlElement).SelectNodes("Content/Morality"))
{
string face = ele.GetAttribute("Face");
if (!table.Columns.Contains("綜合表現:" + face))
{
table.Columns.Add("綜合表現:" + face);
}
}
#endregion
#region 缺曠對照表
List<K12.Data.PeriodMappingInfo> periodMappingInfos = K12.Data.PeriodMapping.SelectAll();
Dictionary<string, string> dicPeriodMappingType = new Dictionary<string, string>();
List<string> periodTypes = new List<string>();
foreach (K12.Data.PeriodMappingInfo periodMappingInfo in periodMappingInfos)
{
if (!dicPeriodMappingType.ContainsKey(periodMappingInfo.Name))
dicPeriodMappingType.Add(periodMappingInfo.Name, periodMappingInfo.Type);
if (!periodTypes.Contains(periodMappingInfo.Type))
periodTypes.Add(periodMappingInfo.Type);
}
foreach (var absence in K12.Data.AbsenceMapping.SelectAll())
{
foreach (var pt in periodTypes)
{
string attendanceKey = pt + "_" + absence.Name;
if (!table.Columns.Contains(attendanceKey))
{
table.Columns.Add(attendanceKey);
}