Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8446429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:55:53+00:00 2026-06-10T09:55:53+00:00

I am setting up a WCF web service that hosts a Lucene.Net / AzureDirectory

  • 0

I am setting up a WCF web service that hosts a Lucene.Net / AzureDirectory search engine.

For speed purposes, the recommended way to use AzureDirectory is to have an singleton IndexSearcher instance that can be used by all service calls. Here is what I have to do that:

public class LuceneHelper
{    
    private static IndexSearcher _searcher;
    public static IndexSearcher searcher
    {
        get
        {
            if (_searcher == null)
                initSearcher();
            return _searcher;
        }
    }
    public static void initSearcher()
    {
        _searcher = new IndexSearcher(azureDirectory);
    }
    ...
}

Since that object caches the index it is searching I need to reinitialize that object on an interval asynchronously from any client calls… like every minute or so. So I tried to setup a process running in another thread on my azure instance that does this…

LuceneHelper.initSearcher();
while (true)
{
    Thread.Sleep(60000);
    LuceneHelper.initSearcher();
}

I can tell from my testing that they both are working but independently of each other. So I guess there is an IndexSearcher in my web service and one in my worker thread.

My Question: Is there a way to run my infinite ‘while’ statement in my webservice asynchronously or any other way to reinitialize an object without a call from a client?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T09:55:54+00:00Added an answer on June 10, 2026 at 9:55 am

    Answering your direct question, yes, it’s possible to have the while statement run in the background of your webservice. All you have to do is create an instance of the Thread class and have it run your loop and store a reference to it in your application (your singleton class would be a good place).

    That said, I wouldn’t recommend this, as you don’t need to open/close/reopen the IndexSearcher class. The recommended practice is to maintain a shared IndexWriter instance for the life of your app and then call the GetReader method to get an IndexReader instance on-demand (from which you can then create an IndexSearcher). This is generally much faster and more maintainable than recreating the index (and it’s real-time as well, as the call to GetReader will have all the changes to the index).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm setting up a net.tcp WCF service using instructions here: http://blogs.msdn.com/swiss_dpe_team/archive/2008/02/08/iis-7-support-for-non-http-protocols.aspx One of the
I am consuming a web service in .NET application with WCF client. The Endpoint's
I've got a WPF windows client that calls a WCF web service. The user
I have a WCF web service that works perfectly with an http address, but
I'm having a problem with setting up a WCF web service integration with a
I have followed some tutorials on setting up a WCF web service with security
I use WCF to consume a web service that respect the WS form (I
I have A WCF service that has a class that inherits System.Web.Security.RoleProvider. In this
NET web application and a WCF Application that share the same ASP.NET membership database.
I just switched my .asmx web service to WCF (both in .NET 3.5), and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.