private static void watchdog_routine() { bool do_watch = false; bool watching = true; m_active = true; while (watching) { lock ( m_form ){ do_watch = m_do_watch; watching = m_watching; }; if (!watching) { break; } ; if (!do_watch) { lock ( m_monitor ){ Monitor.Wait(m_monitor); }; continue; } ; m_items.Clear(); m_process = true; m_form.Invoke(new Action(() => { m_form.pb_progress.Visible = true; m_form.pb_progress.Value = 0; m_form.pb_progress.Maximum = m_form.lv_files.Items.Count; foreach (ListViewItem li in m_form.lv_files.Items) { m_items.Add(li); } ; })); foreach (ListViewItem li in m_items) { conv_core.cImageFile img = li.Tag as conv_core.cImageFile; if (img.crc == img.new_crc) { img.new_crc = conv_core.workbench.file_crc(img.path); if (img.crc != img.new_crc) { li.BackColor = MainForm.cell_back_modified; } ; m_form.Invoke(new Action(() => { m_form.pb_progress.PerformStep(); })); } ; } ; m_form.Invoke(new Action(() => { m_form.pb_progress.Visible = false; })); m_process = false; lock ( m_form ){ m_do_watch = false; }; } ; lock ( m_exit_watch ){ m_active = false; Monitor.PulseAll(m_exit_watch); }; }
private static void thread_routine(object reference) { List <ListViewItem> pool = reference as List <ListViewItem>; bool do_cancel = false; lock ( m_form ){ do_cancel = m_cancel; }; while (!do_cancel && (0 < pool.Count)) { bool mod_flag = true; bool do_mod = false; ListViewItem li = pool.First(); conv_core.cImageFile src_img = li.Tag as conv_core.cImageFile; if (src_img.enabled) { int coverted = 0; foreach (ColumnHeader hdr in m_form.m_formats) { if (!(li.SubItems[hdr.Index].Tag as conv_core.cImageFile).enabled) { li.SubItems[hdr.Index].BackColor = MainForm.cell_back_disabled; coverted++; continue; } ; conv_core.cFormat fmt = hdr.Tag as conv_core.cFormat; ListViewItem.ListViewSubItem lsi = li.SubItems[hdr.Index]; if (fmt.convert(src_img, lsi.Tag as conv_core.cImageFile)) { lsi.BackColor = Color.LightGreen; coverted++; } else { lsi.BackColor = Color.LightPink; }; } ; if (m_form.m_formats.Count == coverted) { li.BackColor = MainForm.cell_back_done; if (mod_flag && (src_img.crc != src_img.new_crc)) { do_mod = true; } ; src_img.crc = src_img.new_crc; } else if (src_img.crc == src_img.new_crc) { li.BackColor = MainForm.cell_back_error; } ; src_img.close(); } ; pool.RemoveAt(0); lock ( m_form ){ m_form.Invoke(new Action(() => { m_form.pb_progress.PerformStep(); })); if (mod_flag && do_mod) { m_form.Invoke(new Action(() => { m_form.t_mod.Enabled = true; })); mod_flag = false; } ; do_cancel = m_cancel; }; } ; }