C# XMLRPC Multi Threaded newPost something is not right
- by user1047463
I recently decided to get my feet wet with c# multi threading and my progress was good until now. My program uses XML-RPC to create new posts on wordpress.
When I run my app on the localhost everything works fine and i successfully able to create new posts on wordpress using a multi threaded approach. However when I try to do the same with a wordpress installed on a remote server , new posts won't appear, so when i go to see all posts, the total number of posts remains unchanged.
Another thing to note is the function that creates a new post does return the ID of a supposedly created posts. But as I mentioned previously the new posts are not visible when I try to access them in admin menu.
Since I'm new to the multithreading I was hoping some of you guys can help me and check if I'm doing anything wrong. Heres the code that creates threads and calls create post function.
foreach (DataRow row in dt.Rows)
{
Thread t = null;
t = new Thread(createPost);
lock (t)
{
t.Start();
}
}
public void createPost()
{
string postid;
try
{
icp = (IcreatePost)XmlRpcProxyGen.Create(typeof(IcreatePost));
clientProtocol = (XmlRpcClientProtocol)icp;
clientProtocol.Url = xmlRpcUrl;
postid = icp.NewPost(1, blogLogin, blogPass, newBlogPost, 1);
currentThread--;
threadCountLabel.Invoke(new MethodInvoker(delegate { threadCountLabel.Text = currentThread.ToString(); }));
}
catch (Exception ex)
{
MessageBox.Show( createPost ERROR ->" + ex.Message);
}
}