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 7493921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:14:11+00:00 2026-05-29T17:14:11+00:00

I’m developing a database application for Windows Phone 7.5 (mango). I trying (during tapping

  • 0

I’m developing a database application for Windows Phone 7.5 (mango). I trying (during tapping on a button) to update a textblock with the text “Searching…” This button performs a rather lengthy search in a big table and thus I want to inform the user. However everything I trying is failed! Here is one of the code snippets that I used. Is there any way to achieve this? Any help helping me understand what’s wrong would be appreciated.

private void btnSearch_Tap(object sender, GestureEventArgs e)
{
    workerThread = new Thread(new ThreadStart(turnVisibilityOn));
    workerThread.Start();
    while (!workerThread.IsAlive) ;
    Thread.Sleep(500);

    //Search database takes about 15 sec on windows phone device!
    Procedures[] results = CSDatabase.RunQuery<Procedures>(@"select Code, Description from tblLibraries where Description like '%" +
    textBox1.Text + "%' or Code like '%" + textBox1.Text + "%'");

    this.MyListBox.ItemsSource = results;

    // Of course this not work
    Search1.Text = ""

}

private void turnVisibilityOn()
{
    // Inform the user updating the Search1 textblock
    // UIThread is a static class -Dispatcher.BeginInvoke(action)-
    UIThread.Invoke(() => Search1.Text = "Searching...");

}


public static class UIThread
{
   private static readonly Dispatcher Dispatcher;

       static UIThread()
       {
       // Store a reference to the current Dispatcher once per application
       Dispatcher = Deployment.Current.Dispatcher;
       }

       /// <summary>
       ///   Invokes the given action on the UI thread - if the current thread is the UI thread this will just invoke the action directly on
       ///   the current thread so it can be safely called without the calling method being aware of which thread it is on.
      /// </summary>
     public static void Invoke(Action action)
     {
         if (Dispatcher.CheckAccess())
         action.Invoke();
         else
         Dispatcher.BeginInvoke(action);
     }
}
  • 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-05-29T17:14:12+00:00Added an answer on May 29, 2026 at 5:14 pm

    I am not sure I understand the problem correctly.
    The “Searching…” text does not show up? The

    // Of course this not work
    Search1.Text = ""
    

    line doesn’t work? (Why do you write “Of course this not work”? Why wouldn’t it work?)

    I don’t understand why you change the text to “Searching…” in a background thread. You could do it in the UI thread, and make the time-consuming work in the background thread, something like this (I switched to using a ThreadPool):

    private void btnSearch_Tap( object sender, GestureEventArgs e )
    {
        Search1.Text = "Searching..."
    
        ThreadPool.QueueUserWorkItem(p =>
        {
            Procedures[] results = CSDatabase.RunQuery<Procedures>( @"select Code, Description from tblLibraries where Description like '%" +
            textBox1.Text + "%' or Code like '%" + textBox1.Text + "%'" );
    
            // Dispatch manipulation of UI elements:
            Dispatcher.BeginInvoke( () =>
            {
                this.MyListBox.ItemsSource = results;
                Search1.Text = "";
            } );
        } ) ;
    }
    

    You always have to manipulate the UI elements from the UI thread (on which the event handler runs) and you have to do the time-consuming work in a background thread.

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

Sidebar

Related Questions

I have a reasonable size flat file database of text documents mostly saved in
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post

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.