小编lon*_*k99的帖子

奥尔良集群沟通

我试图弄清楚如果在同一个集群中托管2个不同的奥尔良谷物与在同一个虚拟网络中的不同集群中部署2个不同的谷物,将会有多大的性能.有人可以给出一些指导,以及在这种情况下2种谷物如何相互交流.

orleans

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

在代码中使Lucene.Net线程安全

我正在使用Lucene.Net进行搜索,并想知道如何处理这个线程问题.

我有一个类Test的实例,但搜索器在这种情况下不是线程安全的,因为定时器线程可以在提供请求的同时更新索引,并且我确实看到了异常.关于如何使其线程安全的任何指针.

public class Test 
{
    private static object syncObj = new object();

    private System.Threading.Timer timer;

    private Searcher searcher;

    private RAMDirectory idx = new RAMDirectory();

    public Test()
    {
        this.timer = new System.Threading.Timer(this.Timer_Elapsed, null, TimeSpan.Zero, TimeSpan.FromMinutes(3));
    }


    private Searcher ESearcher
    {
        get
        {
            return this.searcher;
        }

        set
        {
            lock (syncObj)
            {
                this.searcher = value;
            }
        }
    }

    public Document CreateDocument(string title, string content)
    {
        Document doc = new Document();
        doc.Add(new Field("A", title, Field.Store.YES, Field.Index.NO));
        doc.Add(new Field("B", content, Field.Store.YES, Field.Index.ANALYZED));
        return doc; …
Run Code Online (Sandbox Code Playgroud)

c# search multithreading lucene.net

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

为什么代码不能编译

为什么代码不能编译,当它做同样的事情时.

错误信息:

无法从System.Action转换为System.Threading.ThreadStart.

码:

// Compiles and works
for (int i = 0; i < 100000; i++)
{
    Thread t = new Thread(() => {
        Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
        Thread.Sleep(100); Interlocked.Increment(ref Count);
    });
    t.Start();
}

// doesn't compile
Action action = () => {
    Console.WriteLine(Thread.CurrentThread.ManagedThreadId);
    Thread.Sleep(100);
    Interlocked.Increment(ref Count);
};

for (int i = 0; i < 100000; i++)
{
    Thread t = new Thread(action);
}
Run Code Online (Sandbox Code Playgroud)

c#

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

标签 统计

c# ×2

lucene.net ×1

multithreading ×1

orleans ×1

search ×1