Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
i have a static string in static class, its getting value from desktop application,

on asp.net i have to check that its null or have value, if it has value , i want to

show it on label (on aspx page) , i have put a backgroud worker in global.asax,
C#
public static BackgroundWorker worker = new BackgroundWorker();
    public static int ID = 0;
  //  public static List<Person> personList = new List<Person>();
    public static string personList;
    public static bool stopWorker = false;
    void Application_Start(object sender, EventArgs e)
    {
        worker.DoWork += new DoWorkEventHandler(DoWork);
        worker.WorkerReportsProgress = true;
        worker.WorkerSupportsCancellation = true;
        worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(WorkerCompleted);
        // Calling the DoWork Method Asynchronously
        worker.RunWorkerAsync();




C#
private static void DoWork(object sender, DoWorkEventArgs e)
{
    //foreach (Person p in personList)
    //{
    personList = Class1.GetDataFromDesktop;
    //}
}



its checking value time to time, but i am unable to show the response on label which is on aspx page
, what to do, is there any other process or i can do it using global.asax
Posted
Comments
ZurdoDev 13-Jul-15 12:42pm    
Where are you lost? You say you need your webapp to get a value from the desktop app? From your code sample, it looks like you are calling Class1.GetDataFromDesktop which implies you have code to get the data. Putting that in a label is the easy part. Label1.Text = Class1.GetDataFromDesktop so where exactly are you stuck?
Karachi Coder 13-Jul-15 14:27pm    
the value of GetDataFromDesktop is continuously changing , a i want aspx page to be refreshed when ever the value of 'getDataFromDesktop' changed.
it sets as 'varified' and 'notVarified'
ZurdoDev 13-Jul-15 14:29pm    
I think you misunderstand how the web works. Code does not run in the web until someone visits the page. The server then executes the page and sends html to the client and then disconnects.

You'll want to use the setTimeout function in JS and call a webservice to get the value.
Karachi Coder 13-Jul-15 14:46pm    
i am getting value from web service, web service setting the value of GetDataFromDesktop, i just want a page_load fire, when value of this variable changed, so i set the label , and show the response to aspx. any other way?
ZurdoDev 13-Jul-15 14:47pm    
A web page is dead. It is not connected. So, you have to do something for the code to run on the server and come back to your webpage.

So, use JavaScript's setTimeout method. It fires every x milliseconds on the client side. It's very easy to use.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900