private void refresh_workers_display() { foreach (Control c in panel1.Controls) { if (c is work_item) { work_item item = c as work_item; item.refresh(); } } }
private void timer4_Tick(object sender, EventArgs e) { if (is_running.Value && is_miner_running.Value) //times { db.update_or_insert("insert into times (id_pool, dat) values (" + current_id_running + ", '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "'); "); foreach (Control c in panel1.Controls) { if (c is work_item) { work_item item = c as work_item; if (item.get_id() == current_id_running) { item.refresh(); } } } } }
private void sort_workers(bool allow_change_coin = true, bool skip_check = false) { //unfreeze DateTime dt_now = DateTime.Now; foreach (var itt in enabled_workers) { if (itt.Value.stopped_before != DateTime.MinValue) { if (itt.Value.stopped_before < dt_now) { itt.Value.stopped_before = DateTime.MinValue; } } } var lnq = from it in enabled_workers orderby it.Value.cant_run, it.Value.stopped_before, it.Value.get_diff() select it; List <int> s = new List <int>(); foreach (var itt in lnq) { s.Add(itt.Key); } if (!s.SequenceEqual(currnet_sort)) { //check threshold delta and min_running time if (allow_change_coin && !skip_check) { double current_d = 0; double f_d = 0; int test_next_id = 0; int min_running = 0; DateTime start_running = DateTime.MinValue; bool check_ok = true; for (int i = 0; i < currnet_sort.Count; ++i) { int id = currnet_sort[i]; work_item_struct it = enabled_workers[id]; if (i == 0) { f_d = it.get_diff(); test_next_id = id; } if (id == current_id_running) { current_d = it.get_diff(); min_running = it.min_running; start_running = it.start_running; if (it.cant_run || it.stopped_before != DateTime.MinValue) { check_ok = false; } } } if (check_ok) { if (test_next_id != current_id_running) { if (current_d - f_d < threshold_switch_delta) { refresh_workers_display(); return; } } if (min_running != 0 && (int)((DateTime.Now - start_running).TotalMinutes) < min_running) { refresh_workers_display(); return; } } } bool change_coin = false; currnet_sort = s; panel1.Controls.Clear(); for (int i = 0; i < currnet_sort.Count; ++i) { int id = currnet_sort[i]; work_item_struct it = enabled_workers[id]; if (i == 0) { it.is_running = true; if (it.id != current_id_running) { change_coin = true; current_id_running = it.id; } } else { it.is_running = false; } work_item item = new work_item(); item.init(ref it); item.Left = 3; item.Top = (panel1.Controls.Count * (item.Height + 3)) + 3; panel1.Controls.Add(item); } if (change_coin && allow_change_coin) { refresh_workers_display(); richTextBox2.AppendText("\n[strategy] ", Color.Green); richTextBox2.AppendText("Changing coin"); is_running.Value = false; autostart_flag = true; } } }