小编Mah*_*esh的帖子

c#-进度条[Threading]跨线程操作无效:控制'progressBar'从其他线程(而不是在其上创建的线程)访问

我坚持上述问题。我有很多解决方案,但没有一个对我有用。请在这里找到我的代码

private void btnRunQuery_Click(object sender, EventArgs e)
    {
        try
        {

            Thread ProcessThread = new Thread(Process);
            ProcessThread.Start();

            Thread.CurrentThread.Join();
        }
        catch
        {
            Debug.WriteLine("Error in model creation");
            Console.WriteLine("Error in model creation");
        }
        finally
        {
            //dsModel = null;
        }
    }


private void Process()
    {

        using (var dataContext = new IControlerDataContext())
        {
            dataContext.EnlistTransaction();

            IItemPropertyRepository itemPropertyRepository = ObjectContainer.Resolve<IItemPropertyRepository>();
            IList<ItemProperty> itemPropertyCollection = itemPropertyRepository.LoadAll();
            totalCount = itemPropertyCollection.Count;
            currentCount = 0;

            foreach (var itemProperty in itemPropertyCollection)
            {
                try
                {
                    message = string.Empty;
                    currentCount++;
                    if (itemProperty.DeletedDate == null && (itemProperty.MetaItemProperty.ValueType …
Run Code Online (Sandbox Code Playgroud)

c#-3.0

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

c#-3.0 ×1