WordPress database error: [INSERT, UPDATE command denied to user '51213-2'@'10.10.20.113' for table 'wp_options']INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`) VALUES ('_transient_doing_cron', '1714722008.1106710433959960937500', 'yes') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)
Today I faced a specific need withing a WPF application: I have a well-tested and already in production code which works well for a given user and I need to create an application to execute the same “one-thread\/context” code for a lot of users at the same time. <\/strong>The code uses a lot of static fields, properties and can’t be run as it is in different threads. 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.<\/strong><\/p>\n To have this working I have to perform these steps:<\/p>\n <\/p>\n The code for the StartPoint class is very easy :<\/p>\n 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.<\/p>\n Happy coding !<\/p>\n","protected":false},"excerpt":{"rendered":" Today I faced a specific need withing a WPF application: I have a well-tested and already in production code which works well for a given user and I need to create an application to execute…<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,49,4],"tags":[56,15],"_links":{"self":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts\/1588"}],"collection":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/comments?post=1588"}],"version-history":[{"count":10,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts\/1588\/revisions"}],"predecessor-version":[{"id":1600,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts\/1588\/revisions\/1600"}],"wp:attachment":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/media?parent=1588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/categories?post=1588"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/tags?post=1588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}
\n<\/p>\n\n
\r\npublic class MonPointDentree : MarshalByRefObject\r\n{\r\n public static string Context;\r\n\r\n public void Execute(string input)\r\n {\r\n \/\/ Task can't be marshalled : let's wait\r\n ExecuteAsync(input).Wait();\r\n }\r\n\r\n private async Task ExecuteAsync(string input)\r\n {\r\n Debug.WriteLine(\"[BEFORE] \" + Context);\r\n Context = input;\r\n Debug.WriteLine(\"[AFTER] \" + Context);\r\n\r\n \/\/ call my legacy code here\r\n }\r\n}\r\n<\/pre>\n
\r\nprivate static void LaunchProcess()\r\n{\r\n for (int i = 0; i < 10; i++)\r\n {\r\n var domain = AppDomain.CreateDomain(\"MonAppDomain_\" + i);\r\n\r\n var startPoint = (MonPointDentree)domain\r\n .CreateInstanceAndUnwrap(\"MaDllAPart\", \"MaDllAPart.StartPoint\");\r\n\r\n startPoint.Execute(\"module \" + i);\r\n }\r\n}\r\n<\/pre>\n