WordPress database error: [INSERT, UPDATE command denied to user '51213-2'@'10.10.20.81' for table 'wp_options']INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`) VALUES ('_transient_doing_cron', '1715197332.7802529335021972656250', 'yes') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)
The solution I ended up with is to create an AppDomain by “worker” and to execute the already existing code in each one. The context will be unique in each AppDomain and I will be able to reuse my existing code.
To have this working I have to perform these steps:
The code for the StartPoint class is very easy :
public class MonPointDentree : MarshalByRefObject { public static string Context; public void Execute(string input) { // Task can't be marshalled : let's wait ExecuteAsync(input).Wait(); } private async Task ExecuteAsync(string input) { Debug.WriteLine("[BEFORE] " + Context); Context = input; Debug.WriteLine("[AFTER] " + Context); // call my legacy code here } }
The “MaDllAPart” is added as a reference to the WPF project : this let’s me create an instance of StartPoint without special configuration from my side. Be sure to use the full name (with the namespace) of the instanciated type.
private static void LaunchProcess() { for (int i = 0; i < 10; i++) { var domain = AppDomain.CreateDomain("MonAppDomain_" + i); var startPoint = (MonPointDentree)domain .CreateInstanceAndUnwrap("MaDllAPart", "MaDllAPart.StartPoint"); startPoint.Execute("module " + i); } }
Happy coding !
]]>