小编Weg*_*ged的帖子

在Xaml中声明元组

有没有办法在xaml中声明一个元组,所以我可以将它用作转换器参数?

c# wpf xaml tuples

8
推荐指数
1
解决办法
3370
查看次数

如何在C#和TPL中并行处理事件

我有一个事件,当被解雇时,订阅者执行一些可能需要一段时间才能返回的数据库代码.我想并行执行所有订阅者委托.我正在尝试使用Parallel.Foreach,但我无法得到任何建议吗?

我目前正在尝试沿着这些方向做点什么.

Parallel.ForEach(FacilitiesChanged.GetInvocationList(),某种lambda表达式)

其中FacilitiesChanged是一个事件.

c# parallel-processing events delegates task-parallel-library

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

C#线程静态变量

我有一个实现单例模式的静态DataLibrary类.

        public static FacilityRepository FacilRepo
        {
            get
            {
                if (_facilRepo == null)
                {
                    _facilRepo = new FacilityRepository(Authenticated.UserId);
                    if (Authenticated.FacKey.Length > 0)
                    {
                        foreach (var fac in _facilRepo)
                            fac.IsSelected = (fac.FacilityKey == Authenticated.FacKey);                        
                    }
                }
                return _facilRepo;
            }
        }

private static FacilityRepository _facilRepo;
Run Code Online (Sandbox Code Playgroud)

当我使用Task.Factory.StartNew从不同的线程访问它时,FacilityReposity会多次重新创建,我该如何避免这种情况.

c# static multithreading task

0
推荐指数
1
解决办法
5330
查看次数