Hi,
Im new to Nlog.
I manged to connecto to MySql and write logs to a table.
Now I want to do it Async.
I added AsyncWrapper to my xml configuration file. nothing was written to the DB.
I added Flush() in my own wrapper program. it took the same amount of time - approx 1 minute for 50 records.
There is no example of how to do it with DB, only with file, Can someone please post an example for Async connection to a DB that works.
10x in advance
Jacob
解决方案I''m not sure this is the right way to do it, but you can try this:
using System.ComponentModel;
using MySql.Data.MySqlClient;
public void Flush()
{
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += (sender, e) =>
{
// do some work, just an example
e.Result = MySqlHelper.ExecuteNonQuery("your-connectionstring-here", "your-commandtext-here");
// do some work
};
worker.RunWorkerCompleted += (sender, e) =>
{
MessageBox.Show((int)e.Result + " rows affected.", "Success");
};
worker.RunWorkerAsync();
}