本文整理汇总了C#中BackgroundWorker.ReportProgress方法的典型用法代码示例。如果您正苦于以下问题:C# BackgroundWorker.ReportProgress方法的具体用法?C# BackgroundWorker.ReportProgress怎么用?C# BackgroundWorker.ReportProgress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BackgroundWorker
的用法示例。
在下文中一共展示了BackgroundWorker.ReportProgress方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReportProgressNonBusy
public void ReportProgressNonBusy()
{
var b = new BackgroundWorker<object, object, object>
{
WorkerReportsProgress = true
};
Assert.IsFalse(b.IsBusy);
b.ReportProgress(0);
}
示例2: TestBackgroundWorkerBasic
public void TestBackgroundWorkerBasic()
{
var orignal = SynchronizationContext.Current;
try
{
SynchronizationContext.SetSynchronizationContext(null);
const int expectedResult = 42;
const int expectedReportCallsCount = 5;
int actualReportCallsCount = 0;
var worker = new BackgroundWorker() { WorkerReportsProgress = true };
var progressBarrier = new Barrier(2, barrier => ++actualReportCallsCount);
var workerCompletedEvent = new ManualResetEventSlim(false);
worker.DoWork += (sender, e) =>
{
for (int i = 0; i < expectedReportCallsCount; i++)
{
worker.ReportProgress(i);
progressBarrier.SignalAndWait();
}
e.Result = expectedResult;
};
worker.RunWorkerCompleted += (sender, e) =>
{
try
{
Assert.Equal(expectedResult, (int)e.Result);
Assert.False(worker.IsBusy);
}
finally
{
workerCompletedEvent.Set();
}
};
worker.ProgressChanged += (sender, e) =>
{
progressBarrier.SignalAndWait();
};
worker.RunWorkerAsync();
// wait for singal from WhenRunWorkerCompleted
Assert.True(workerCompletedEvent.Wait(TimeoutLong));
Assert.False(worker.IsBusy);
Assert.Equal(expectedReportCallsCount, actualReportCallsCount);
}
finally
{
SynchronizationContext.SetSynchronizationContext(orignal);
}
}
示例3: TestReportProgressSync
public void TestReportProgressSync()
{
var bw = new BackgroundWorker() { WorkerReportsProgress = true };
var expectedProgress = new int[] { 1, 2, 3, 4, 5 };
var actualProgress = new List<int>();
bw.ProgressChanged += (sender, e) =>
{
actualProgress.Add(e.ProgressPercentage);
};
foreach (int i in expectedProgress)
{
bw.ReportProgress(i);
}
Assert.Equal(expectedProgress, actualProgress);
}
示例4: GetPlayers
public static ObservableCollection<Player> GetPlayers(BackgroundWorker worker = null)
{
ObservableCollection<Player> players = new ObservableCollection<Player>();
OracleConnection cn = null;
OracleCommand cmd = null;
OracleDataReader rdr = null;
DataTable tbl = null;
int i = 0;
try
{
List<Tidbit> tidbits = GetAllPlayerTidbitsSDR();
cn = createConnectionSDR();
if (cn != null)
{
String sql = "";
switch (ConfigurationManager.AppSettings["DraftType"].ToUpper())
{
case "LHN":
case "NFL":
sql = "select a.*, b.*, c.* ";
sql += "from espnews.draftplayers a left join espnews.news_teams b on a.schoolid = b.team_id left join espnews.draftorder c on a.pick = c.pick order by a.pick asc, lastname asc, firstname asc";
break;
case "NBA":
sql = "select a.*, b.*, c.*, (select text from espnews.drafttidbits where referencetype = 1 and referenceid = a.playerid and tidbitorder = 999) as tradetidbit ";
sql += "from espnews.draftplayers a left join espnews.news_teams b on a.schoolid = b.team_id left join espnews.draftorder c on a.pick = c.pick order by a.pick asc, lastname asc, firstname asc";
break;
}
cmd = new OracleCommand(sql, cn);
rdr = cmd.ExecuteReader();
tbl = new DataTable();
tbl.Load(rdr);
rdr.Close();
rdr.Dispose();
foreach (DataRow row in tbl.Rows)
{
Player player = createPlayerModel(row, tidbits);
players.Add(player);
i++;
int percent = Convert.ToInt32(((double)i / tbl.Rows.Count) * 100);
if (worker != null)
{
worker.ReportProgress(percent);
}
}
}
else
{
System.Windows.MessageBox.Show("There was a problem connecting to the SDR database");
}
}
finally
{
if (cmd != null) cmd.Dispose();
if (tbl != null) tbl.Dispose();
if (cn != null) cn.Close(); cn.Dispose();
}
return players;
}
示例5: ImportTeams
//.........这里部分代码省略.........
{
row = tbl.Rows.Add();
row["referencetype"] = 2;
row["referenceid"] = xmlRow["teamid"];
row["tidbitorder"] = 20;
}
else
{
row = tbl.Rows[0];
}
row["text"] = xmlRow["record"].ToString();
row["enabled"] = 1;
adp.Update(tbl.GetChanges());
tbl.AcceptChanges();
cmd.Dispose();
adp.Dispose();
bldr.Dispose();
tbl.Dispose();
#endregion
#region Lineup
sql = "select * from espnews.drafttidbits where referencetype = 2 and tidbitorder = 30 and referenceid = " + xmlRow["teamid"];
cmd = new OracleCommand(sql, cn);
adp = new OracleDataAdapter(cmd);
bldr = new OracleCommandBuilder(adp);
tbl = new DataTable();
adp.Fill(tbl);
if (tbl.Rows.Count == 0)
{
row = tbl.Rows.Add();
row["referencetype"] = 2;
row["referenceid"] = xmlRow["teamid"];
row["tidbitorder"] = 30;
}
else
{
row = tbl.Rows[0];
}
row["text"] = xmlRow["lineup"].ToString();
row["enabled"] = 1;
adp.Update(tbl.GetChanges());
tbl.AcceptChanges();
cmd.Dispose();
adp.Dispose();
bldr.Dispose();
tbl.Dispose();
#endregion
}
teamsImported++;
}
worker.ReportProgress(teamsImported / teamsToImport);
} //foreach team
} //try
catch (Exception ex)
{
importErrors++;
}
finally
{
if (cmd != null) cmd.Dispose();
if (adp != null) adp.Dispose();
if (bldr != null) bldr.Dispose();
if (rdr != null) rdr.Dispose();
if (cn != null) cn.Close(); cn.Dispose();
//log.Close();
}
}; //dowork
worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args)
{
SetStatusBarMsg(teamsImported.ToString() + " of " + teamsToImport.ToString() + " teams successfully imported at " + DateTime.Now.ToLongTimeString(), "Green");
GlobalCollections.Instance.LoadTeams();
};
worker.ProgressChanged += delegate(object s, ProgressChangedEventArgs args)
{
SetStatusBarMsg(teamsImported.ToString() + " of " + teamsToImport.ToString() + " teams imported.", "Yellow");
};
worker.RunWorkerAsync(file);
}
示例6: ImportPlayers
//.........这里部分代码省略.........
if (ConfigurationManager.AppSettings["DraftType"].ToString().ToUpper() == "NBA")
{
noteCount = 2;
}
else
{
noteCount = 4;
}
for (int i = 1; i <= noteCount; i++)
{
if (xmlRow.Table.Columns["matrixnote" + i.ToString()] != null)
{
if (xmlRow["matrixnote" + i.ToString()].ToString().Trim() != "")
{
sql = "select * from espnews.drafttidbits where referenceid = " + xmlRow["playerid"] + " and referencetype = 1 and tidbitorder = " + i;
cmd = new OracleCommand(sql, cn);
adp = new OracleDataAdapter(cmd);
bldr = new OracleCommandBuilder(adp);
tblTids = new DataTable();
DataRow rowTids = null;
adp.Fill(tblTids);
if (tblTids.Rows.Count == 0)
{
rowTids = tblTids.Rows.Add();
rowTids["referenceid"] = xmlRow["playerid"];
rowTids["referencetype"] = 1;
rowTids["tidbitorder"] = i;
rowTids["enabled"] = 1;
}
else
{
rowTids = tblTids.Rows[0];
}
rowTids["text"] = xmlRow["matrixnote" + i.ToString()].ToString();
adp.Update(tblTids.GetChanges());
tblTids.AcceptChanges();
cmd.Dispose();
adp.Dispose();
bldr.Dispose();
tblTids.Dispose();
}
}
}
}
finally
{
if (tblTids != null) tblTids.Dispose();
}
playersImported++;
worker.ReportProgress(playersImported / playersToImport);
} //playerid > 0
else
{
playersNotFound++;
// //write to report file with this player, not found
// log.WriteLine(DateTime.Now + " --- Not found: " + xmlRow["firstname"].ToString() + " " + xmlRow["lastname"].ToString());
}
} //foreach player
} //try
catch (Exception ex)
{
importErrors++;
}
finally
{
if (cmd != null) cmd.Dispose();
if (adp != null) adp.Dispose();
if (bldr != null) bldr.Dispose();
if (rdr != null) rdr.Dispose();
if (cn != null) cn.Close(); cn.Dispose();
//log.Close();
}
}; //dowork
worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args)
{
SetStatusBarMsg(playersImported.ToString() + " of " + playersToImport.ToString() + " players successfully imported at " + DateTime.Now.ToLongTimeString() + ". Players not found by ID: " + playersNotFound.ToString() + ". Errors importing " + importErrors.ToString() + ".", "Green");
GlobalCollections.Instance.LoadPlayers();
};
worker.ProgressChanged += delegate(object s, ProgressChangedEventArgs args)
{
SetStatusBarMsg(playersImported.ToString() + " of " + playersToImport.ToString() + " players imported.", "Yellow");
};
worker.RunWorkerAsync(file);
}
示例7: ReportProgressNoReportingSupported
public void ReportProgressNoReportingSupported()
{
var b = new BackgroundWorker<object, object, object>();
Assert.IsFalse(b.IsBusy);
b.ReportProgress(0);
}
示例8: ReadAirAsiaDetails
private void ReadAirAsiaDetails(BackgroundWorker worker, string filename, out DateTime flightDate, out string flightNo, out List<PAUPassenger> passangers)
{
flightDate = DateTime.Now;
flightNo = "";
passangers = new List<PAUPassenger>();
using (StreamReader reader = new StreamReader(filename))
{
char[] separator = { ',', '/' };
string line;
string fno = "";
DateTime flight_date = DateTime.MinValue;
string num = "", pnr = "", last_name = "", first_name = "";
string gender = "", dob = "", nat = "";
bool start = false;
bool parse = false;
// bool found_first = false;
BeaCukai cukai = new BeaCukai();
int lineNo = 1;
while ((line = reader.ReadLine()) != null)
{
if (worker != null)
{
worker.ReportProgress(lineNo, line);
}
lineNo++;
if (line.Contains("Pax Verification"))
{
start = true;
continue;
}
if (line.Contains("------------------") && start)
{
parse = true;
continue;
}
if (line.Trim() == "")
{
parse = false;
}
if (line.Contains("Flight") && line.Contains("Date:"))
{
int flightPos = line.IndexOf("Flight#:") + 8;
int datePos = line.IndexOf("Date:") + 5;
fno = line.Substring(flightPos, 6).Trim();
string fdate = line.Substring(datePos, 14).Trim();
string[] dates = fdate.Split(separator);
if (dates.Count() > 0)
{
ConvertPAXStringToDate(dates[0], out flightDate);
ConvertPAXStringToDate(dates[0], out flight_date);
}
flightNo = fno;
continue;
}
if (parse)
{
int number = -1;
try
{
number = Int32.Parse(line.Substring(0, 3).Trim());
}
catch (Exception)
{
number = -1;
}
if (number > -1)
{
pnr = line.Substring(5, 6).Trim();
last_name = line.Substring(12, 25).Trim();
first_name = line.Substring(37, line.Length - 37).Trim();
num = number.ToString();
if ((line = reader.ReadLine()) != null)
{
//found_first = false;
char[] sep = { ' ' };
//string[] datas = line.Split(sep);
gender = line.Substring(11, 2).Trim();
dob = line.Substring(13, 6).Trim();
nat = line.Substring(22, 3).Trim();
//MessageBox.Show(line+#13);
PAUPassenger pass = null;
try
{
pass = (from p in cukai.PAUPassenger select p).Where(p => p.FirstName.ToLower() == first_name.ToLower()).
Where(p => p.LastName.ToLower() == last_name.ToLower()).
Where(p => p.FlightNo.ToLower() == fno.ToLower()).
//.........这里部分代码省略.........
示例9: GetProTeams
public static ObservableCollection<Team> GetProTeams(BackgroundWorker worker = null)
{
ObservableCollection<Team> teams = new ObservableCollection<Team>();
MySqlConnection cn = null;
MySqlCommand cmd = null;
MySqlDataReader rdr = null;
DataTable tbl = null;
int i = 0;
try
{
cn = createConnectionMySql();
String sql = "select * from teams where league = '" + ConfigurationManager.AppSettings["DraftType"].ToString() + "' order by city asc, name asc";
cmd = new MySqlCommand(sql, cn);
rdr = cmd.ExecuteReader();
tbl = new DataTable();
tbl.Load(rdr);
rdr.Close();
rdr.Dispose();
Team team;
foreach (DataRow row in tbl.Rows)
{
team = new Team();
team.ID = Convert.ToInt32(row["id"]);
team.FullName = row["city"].ToString() + " " + row["name"].ToString();
team.Tricode = row["tricode"].ToString();
team.City = row["city"].ToString();
team.Name = row["name"].ToString();
if (ConfigurationManager.AppSettings["LoadTeamLogos"].ToString().ToUpper() == "TRUE" || ConfigurationManager.AppSettings["LoadTeamLogos"].ToString().ToUpper() == "YES")
{
team.LogoTga = new Uri(row["logo"].ToString());
team.SwatchTga = new Uri(row["swatch"].ToString());
}
team.OverallRecord = row["overallrecord"].ToString();
team.ConferenceRecord = row["conferencerecord"].ToString();
team.Hashtag = row["hashtag"].ToString();
if (row["lotterypctrank"] != DBNull.Value)
{
team.LotteryPctRank = Convert.ToInt16(row["lotterypctrank"].ToString());
}
if (row["lotteryorder"] != DBNull.Value)
{
team.LotteryOrder = Convert.ToInt16(row["lotteryorder"].ToString());
}
if (ConfigurationManager.AppSettings["DraftType"].ToString().ToUpper() == "NBA")
{
team.PickPlateTga = new Uri(ConfigurationManager.AppSettings["PickPlateDirectory"].ToString() + "\\NBA.tga");
}
else
{
team.PickPlateTga = new Uri(ConfigurationManager.AppSettings["PickPlateDirectory"].ToString() + "\\" + row["name"].ToString().ToUpper() + ".tga");
}
if (ConfigurationManager.AppSettings["LoadTeamTidbits"].ToString().ToUpper() == "TRUE" || ConfigurationManager.AppSettings["LoadTeamTidbits"].ToString().ToUpper() == "YES")
{
if (ConfigurationManager.AppSettings["TeamTidbitsDatabase"].ToString().ToUpper() == "MYSQL")
{
team.Tidbits = GetTidbitsMySql(2, Convert.ToInt32(row["id"]));
}
else
{
team.Tidbits = GetTidbitsSDR(2, Convert.ToInt32(row["id"]));
}
}
teams.Add(team);
i++;
int percent = Convert.ToInt32(((double)i / tbl.Rows.Count) * 100);
if (worker != null)
{
worker.ReportProgress(percent);
}
}
}
finally
{
if (cmd != null) cmd.Dispose();
if (tbl != null) tbl.Dispose();
if (cn != null) cn.Close(); cn.Dispose();
}
return teams;
}
示例10: UISave
public void UISave()
{
var bw = new BackgroundWorker();
bw.WorkerReportsProgress = true;
bw.DoWork += delegate(object o, DoWorkEventArgs args)
{
var b = o as BackgroundWorker;
Thread.Sleep(4000);
saveSettings();
bw.ReportProgress(100);
};
bw.RunWorkerCompleted += delegate { uiSaveDelay = false; };
bw.RunWorkerAsync();
}
示例11: PackCachedId
public virtual void PackCachedId(int start, int end,BackgroundWorker worker=null)
{
if (start == end || start > end)
{
throw new ArgumentOutOfRangeException("Invalid range");
}
int range = end - start;
if( SpawnGroups.Count() > range)
{
throw new ArgumentOutOfRangeException("Range specified not large enough");
}
IEnumerable<SpawnGroup> sorted = SpawnGroups.OrderBy(x => x.Id);
int i = start;
var updates = new List<Spawn2>();
foreach (var spawn in sorted)
{
//if we are going to potentially re-insert them all somewhere we might as well delete them
//the update query generates the delete queries first so this works
//create a spawn that keeps track of the identifier so we can delete it
var copy = CreateSpawnGroup();
copy.Id = spawn.Id;
NeedsDeleted.Add(copy);
//spawngroups are associated with 0-n spawn2 entries so these will need updated
foreach (var s2 in copy.GetLinkedSpawn2())
{
//force it to be dirtied
s2.Created();
s2.SpawnGroupId = i;
updates.Add(s2);
}
spawn.UnlockObject();
spawn.Id = i;
spawn.Created();
i += 1;
if (worker != null)
{
double x = i - start;
double y = SpawnGroups.Count();
double percent = x / y * 100;
worker.ReportProgress((int)percent);
}
}
_updateSpawn2 = updates;
}
示例12: BackgroundWorker_RunWorkerAsync_ReportsProgress
public void BackgroundWorker_RunWorkerAsync_ReportsProgress()
{
using (UnitTestContext context = GetContext())
{
BackgroundWorkerSyncContextHelper.DoTests(() =>
{
var UIThreadid = Thread.CurrentThread.ManagedThreadId;
int numTimesProgressCalled = 0;
BackgroundWorker target = new BackgroundWorker();
target.DoWork += (o, e) =>
{
// report progress changed 10 times
for (int i = 1; i < 11; i++)
{
target.ReportProgress(i*10);
}
e.Result = new object();
};
target.WorkerReportsProgress = true;
target.ProgressChanged += (o, e) =>
{
context.Assert.IsTrue(Thread.CurrentThread.ManagedThreadId == UIThreadid);
numTimesProgressCalled++;
};
target.RunWorkerCompleted += (o, e) =>
{
context.Assert.IsTrue(Thread.CurrentThread.ManagedThreadId == UIThreadid);
context.Assert.IsNull(e.Error);
context.Assert.IsTrue(numTimesProgressCalled == 10,"ReportProgress has been called 10 times");
context.Assert.Success();
};
target.RunWorkerAsync(null);
while (target.IsBusy)
{
// this is the equvalent to Application.DoEvents in Windows Forms
BackgroundWorkerSyncContextHelper.PumpDispatcher();
}
context.Complete();
});
}
}
示例13: BackgroundWorker_DoWork_ThrowsInvalidOperationExcpetionWhenWorkerReportsProgressIsFalse
public void BackgroundWorker_DoWork_ThrowsInvalidOperationExcpetionWhenWorkerReportsProgressIsFalse()
{
UnitTestContext context = GetContext();
int numTimesProgressCalled = 0;
BackgroundWorker target = new BackgroundWorker();
target.DoWork += (o, e) =>
{
// report progress changed 10 times
for (int i = 1; i < 11; i++)
{
target.ReportProgress(i * 10);
}
};
target.WorkerReportsProgress = false;
target.ProgressChanged += (o, e) =>
{
numTimesProgressCalled++;
};
target.RunWorkerCompleted += (o, e) =>
{
// target does not support ReportProgress we shold get a System.InvalidOperationException from DoWork
context.Assert.IsTrue(e.Error is System.InvalidOperationException);
context.Assert.Success();
};
target.RunWorkerAsync(null);
context.Complete();
}
示例14: GetAllDocuments
public static void GetAllDocuments(BackgroundWorker worker)
{
GestionConnection.StopAllTimers(false);
ClearLocalDatabase();
ClearLuceneIndex();
ClearLocalStorage();
Dictionary<string, object> arg = new Dictionary<string, object>();
arg.Add("@subdivision", Properties.Settings.Default.subdivisionTablette);
string cmd = @"SELECT idDocument FROM Documents WHERE (subdivision = @subdivision";
if (Properties.Settings.Default.documentsDeService) // Pour récupérer également les documents de service
{
cmd += " OR subdivision = 'Service') ";
}
else
{
cmd += ") ";
}
cmd += "ORDER BY idDocument ASC;";
MySqlDataReader Reader = ConnectorMySql.ExecCommand(cmd, arg);
if(Reader == null){
return;
}
List<UInt32> idsDoc = new List<UInt32>();
while (Reader.Read())
{
idsDoc.Add(Reader.GetUInt32("idDocument"));
}
ConnectorMySql.Close(Reader);
totalDocument = idsDoc.Count;
nbDocCopied = 0;
foreach (uint id in idsDoc)
{
nbDocCopied++;
Document monDocument = new Document(id);
if (monDocument.typeDocument == "DocNormales" && monDocument.subdivision != "Service")
{
Properties.Settings.Default.flagRefreshDocuments = true;
Properties.Settings.Default.flagRefreshAccueil = true;
}
if (monDocument.typeDocument == "DocNormales" && monDocument.subdivision == "Service")
{
Properties.Settings.Default.flagRefreshAccueil = true;
Properties.Settings.Default.flagRefreshNotes = true;
}
if (monDocument.typeDocument == "Consignes")
{
Properties.Settings.Default.flagRefreshAccueil = true;
Properties.Settings.Default.flagRefreshConsignes = true;
}
if (monDocument.typeDocument == "TachesJournalieres")
{
Properties.Settings.Default.flagRefreshAccueil = true;
Properties.Settings.Default.flagRefreshTachesJournalieres = true;
}
if (monDocument.typeDocument == "Verifications")
{
Properties.Settings.Default.flagRefreshAccueil = true;
Properties.Settings.Default.flagRefreshVerifications = true;
}
Properties.Settings.Default.Save();
worker.ReportProgress(nbDocCopied * 100 / totalDocument, id);
monDocument.AjoutLocal();
//Mise en pause du thread pendant 1ms pour la mise à jour des autres threads
System.Threading.Thread.Sleep(0);
}
Reader = ConnectorMySql.ExecCommand(@"SELECT idDocLogs FROM DocLogs
ORDER BY idDocLogs DESC
LIMIT 1;");
if (Reader == null)
{
return;
}
if(Reader.Read())
{
Properties.Settings.Default.lastIdCheckDocLog = Reader.GetUInt32("idDocLogs");
Properties.Settings.Default.Save();
}
ConnectorMySql.Close(Reader);
SetInformationsInServerAboutUpdate();
App.Current.Dispatcher.BeginInvoke(
System.Windows.Threading.DispatcherPriority.Normal,
new Action(
delegate()
{
((MainWindow)App.Current.MainWindow).RefreshUCs();
}
)
);
GestionConnection.LookingForUpdate();
}
示例15: UpdateDocuments
public static void UpdateDocuments(BackgroundWorker worker, UInt32 LastId)
{
//Préparation SQL : récupérer tous les docs logs à partir du dernier checké
// récupérer pour la sub et si activé pour le service
Dictionary<string, object> arg = new Dictionary<string, object>();
arg.Add("@LastId", LastId);
arg.Add("@subdivision", Properties.Settings.Default.subdivisionTablette);
string cmd = @"SELECT * FROM DocLogs
WHERE idDocLogs > @LastId
AND (subdivision = @subdivision ";
if (Properties.Settings.Default.documentsDeService) // Pour récupérer également les documents de service
{
cmd += "OR subdivision = 'Service') ";
}
else
{
cmd += ") ";
}
cmd += "ORDER BY idDocLogs ASC;";
MySqlDataReader Reader = ConnectorMySql.ExecCommand(cmd, arg);
List<DocLog> listDocLogs = new List<DocLog>();
if (Reader != null)
{
//Stockage dans une list du résultat de la requête
while (Reader.Read())
{
listDocLogs.Add(new DocLog(Reader));
}
ConnectorMySql.Close(Reader);
}
else
{
worker.ReportProgress(0, false);
}
if (listDocLogs.Count == 0)
{
SetInformationsInServerAboutUpdate();
return;
}
//Avant le nettoyage on récupère le dernier index idDocLogs et on le stocke
UInt32 dernierIndex = listDocLogs.Last().idDocLogs;
Properties.Settings.Default.lastIdCheckDocLog = dernierIndex;
Properties.Settings.Default.Save();
////Nettoyage des logs du serveur : ADD + DEL = NULL
//for (int i = 0; i < listDocLogs.Count - 1; i++)
//{
// DocLog docLogToCompare = listDocLogs[i];
// for (int j = i + 1; j < listDocLogs.Count; j++)
// {
// DocLog docLogCible = listDocLogs[j];
// if (docLogToCompare.isReductible(docLogCible))
// {
// if (docLogCible.typeModification == "DEL")
// {
// listDocLogs.Remove(docLogToCompare);
// }
// listDocLogs.Remove(docLogCible);
// //A revoir, pour optimisation, après suppression, je remet les indexes à 0 pour ne
// // rater aucun doublon useless...
// i = 0;
// if (listDocLogs.Count > 0)
// {
// //On met à jour le docLogToCompare avec le nouvel index 0
// docLogToCompare = listDocLogs[0];
// }
// j = 0;
// }
// }
//}
listDocLogs = OptimiseDocLogList(listDocLogs);
//J'ai maintenant une liste de DocLogs : listDocLogs qui ne contient que les actions à réellement effectuer sur la doc
totalDocument = listDocLogs.Count;
nbDocCopied = 0;
foreach (DocLog unDocLog in listDocLogs)
{
nbDocCopied++;
//Mise en pause du thread pendant 1ms pour la mise à jour des autres threads
System.Threading.Thread.Sleep(0);
unDocLog.applyChange();
worker.ReportProgress(nbDocCopied * 100 / totalDocument, true);
}
SetInformationsInServerAboutUpdate();
App.Current.Dispatcher.BeginInvoke(
System.Windows.Threading.DispatcherPriority.Send,
new Action(
delegate()
{
((MainWindow)App.Current.MainWindow).RefreshUCs();
}
)
);
}