public override bool PreProcessMessage(ref Message msg)
{
}
public abstract class MyForm : Form
{
protected override void OnActivated(EventArgs e)
{
base.OnActivated(e);
// TODO: Убедиться, что MainForm != null
// System.Diagnostics.Debug.Assert(null != Program.MainForm);
Program.MainForm.Hide();
} // OnActivate
protected override void OnDeactivate(EventArgs e)
{
base.OnDeactivate(e);
// TODO: Убедиться, что MainForm != null
// System.Diagnostics.Debug.Assert(null != Program.MainForm);
Program.MainForm.Show();
} // OnDeactivate
} // class MyForm
using (SqlConnection conn = new SqlConnection(connectionString))
{
string sqlText = "INSERT INTO [Library] (Title, Tags, Body) OUTPUT INSERTED.[Id] VALUES(@Title, @Tags, @Body)";
using (SqlCommand cmd = new SqlCommand(sqlText, conn))
{
cmd.Parameters.AddWithValue("Title", title);
cmd.Parameters.AddWithValue("Tags", tags);
cmd.Parameters.AddWithValue("Body", body);
try
{
conn.Open();
Guid insertedGuid = (Guid)await cmd.ExecuteScalarAsync(); // <-- созданный GUID
}
finally
{
conn.Close();
}
} // using cmd
} // using conn
internal static class Helper
{
internal static void SetUpGridView(DataGridView dgv)
{
// ... делайте всё здесь
}
} // class Helper
Helper.SetUpGridView(this.DataGridView1);
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace TasksSample
{
public class Worker
{
private int id;
public Worker(int id)
{
this.id = id;
}
public void DoHardWork()
{
Console.WriteLine($"Task {this.id} started.");
Random rng = new Random();
int delay = rng.Next(1000, 10000);
Thread.Sleep(delay);
Console.WriteLine($"Task {this.id} finished after {delay} ms.");
} // DoHardWork
} // class Worker
class Program
{
static void Main(string[] args)
{
TaskFactory fact = new TaskFactory();
int TaskCount = 10;
List<Task> myTasks = new List<Task>();
for (int id = 0; id < TaskCount; ++id)
{
Worker w = new Worker(id);
myTasks.Add(fact.StartNew(() => w.DoHardWork()));
}
Task.WaitAll(myTasks.ToArray());
} // void Main
} // class Program
} // namespace TasksSample
FileStream inp_f = new FileStream(name_f1, FileMode.Create);
public class XmlEntry
{
public DateTime Date { get; set; }
public float[] Values { get; set; }
} // class XmlEntry
public IEnumerable<XmlEntry> ReadFile(string filename)
{
XmlDocument doc = new XmlDocument();
doc.Load(filename);
return doc.SelectNodes("dataset/data/datum") // Здесь возможно подредактировать путь надо, у вас XML обрезан
.OfType<XmlElement>()
.Select(e => new XmlEntry
{
Date = DateTime.Parse(
e.ChildNodes.OfType<XmlElement>()
.Where(cn =>
cn.Attributes["type"].Value.Equals("date")).FirstOrDefault().InnerText),
Values =
e.ChildNodes.OfType<XmlElement>()
.Where(cn =>
cn.Attributes["type"].Value.Equals("float"))
.Select(node => float.Parse(node.InnerText, System.Globalization.CultureInfo.InvariantCulture))
.ToArray()
});
} // ReadFile