脚本未在多处理中运行

时间:2015-09-24 06:34:32

标签: python multithreading multiprocessing

我正在尝试在多处理中运行文件,但它在单个进程中运行

using System.Web.Script.Serialization;
using System.Data;
using System.Collections.Generic;
using System;


namespace WebApi.Helpers
{
    public static class JSONHelper
    {
        /// <summary>
        /// Extened method of object class, Converts an object to a json string.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public static string ToJSON(this object obj)
        {
            var serializer = new JavaScriptSerializer();
            try
            {
                return serializer.Serialize(obj);
            }
            catch(Exception ex)
            {
                return "";
            }
        }
    }
}

请告诉我如何在多个过程中运行此脚本?

1 个答案:

答案 0 :(得分:0)

apply功能是阻止功能。您应该使用apply_asyncPool中运行并行任务。