public partial class Form1 : Form
{
private LongTimeJob _ltj;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
_ltj = new LongTimeJob();
button1.Enabled = false;
_ltj.Complete += _ltj_Complete;
_ltj.Tick += _ltj_Tick;
_ltj.Run();
}
private void _ltj_Tick(object sender, TickArgs args) =>
progressBar1.Invoke((MethodInvoker)delegate { progressBar1.Value = args.Percent; });
private void _ltj_Complete(object sender, EventArgs args)
{
button1.Invoke((MethodInvoker)delegate { button1.Enabled = true; });
textBox1.Invoke((MethodInvoker)delegate { textBox1.Text = _ltj.Text; });
}
}
public class LongTimeJob
{
public int Percent { get; private set; }
public string Text { get; private set; } = "";
public void Run()
{
Percent = 0;
Task.Run(async () => await Download());
}
private async Task Download()
{
for (var i = 0; i < 9; i++)
{
Percent = i * 10;
Text += $"Download: {i}\r\n";
OnTick(Percent);
await Task.Delay(400);
}
await Parse();
}
private async Task Parse()
{
Percent = 100;
Text += "Parsing\r\n";
OnTick(Percent);
await Task.Delay(500);
OnComplete();
}
public event TickDelegate Tick;
protected virtual void OnTick(int percent)
{
Tick?.Invoke(this, new TickArgs(percent));
}
public event CompleteDelegate Complete;
protected virtual void OnComplete()
{
Complete?.Invoke(this, new EventArgs());
}
}
public delegate void TickDelegate(object sender, TickArgs args);
public delegate void CompleteDelegate(object sender, EventArgs args);
public class TickArgs : EventArgs
{
public TickArgs(int percent)
{
Percent = percent;
}
public int Percent { get; private set; }
}
документ, еще один документ, ромашка
SELECT name
FROM random AS r1 JOIN
(SELECT CEIL(RAND() *
(SELECT MAX(id)
FROM random)) AS id)
AS r2
WHERE r1.id >= r2.id
ORDER BY r1.id ASC
LIMIT 1
If you do not define a PRIMARY KEY for your table, MySQL locates the first UNIQUE index where all the key columns are NOT NULL and InnoDB uses it as the clustered index.
If the table has no PRIMARY KEY or suitable UNIQUE index, InnoDB internally generates a hidden clustered index named GEN_CLUST_INDEX on a synthetic column containing row ID values. The rows are ordered by the ID thatInnoDB assigns to the rows in such a table. The row ID is a 6-byte field that increases monotonically as new rows are inserted. Thus, the rows ordered by the row ID are physically in insertion order.