其他分享
首页 > 其他分享> > Dynamics CRM 365自动编号重复的并发防止

Dynamics CRM 365自动编号重复的并发防止

作者:互联网

1.Dynamics CRM 365控制并发的处理方式:A.在数据库端控制,可以设置唯一聚集索引来处理。B.在进程端处理

由于自动编号只在Plugin触发,所以这里可以在进程端处理

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            Thread th = new Thread(new ParameterizedThreadStart(thread1));
            th.Name = "111";
            Thread th1 = new Thread(new ParameterizedThreadStart(thread2));
            th1.Name = "222";
            Thread th2 = new Thread(new ParameterizedThreadStart(thread3));
            th2.Name = "333";
            th.Start("11");
            th1.Start("11");
            th2.Start("11");

            Console.ReadKey();
        }
        static void Done(object name)
        {
            Console.WriteLine("开始执行" + Thread.CurrentThread.Name);
            lock (name.ToString())
            {
                Console.WriteLine("进入休眠区" + Thread.CurrentThread.Name);
                Thread.Sleep(20000);
                Console.WriteLine("推出休眠区"+ Thread.CurrentThread.Name);
            }
        }
        static void thread1(object name)
        {
            Done(name);
        }
        static void thread2(object name)
        {
            Done(name);
        }
        static void thread3(object name)
        {
            Done(name);
        }

    }
}

 

标签:name,Thread,System,Name,using,new,Dynamics,365,CRM
来源: https://www.cnblogs.com/parkerchen/p/16371616.html