C# XMLRPC Multi Threaded newPost something is not right

Posted by user1047463 on Stack Overflow See other posts from Stack Overflow or by user1047463
Published on 2011-11-24T09:45:56Z Indexed on 2011/11/24 9:52 UTC
Read the original article Hit count: 522

Filed under:
|
|

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);
            }

        }

© Stack Overflow or respective owner

Related posts about c#

Related posts about multithreading