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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:14:53+00:00 2026-05-26T15:14:53+00:00

i created a wcf service that had a method: public List<Mail> GetMailItems() { //gets

  • 0

i created a wcf service that had a method:

public List<Mail> GetMailItems()
{
//gets mails from database which were created in last two minutes

return Mails;
}

the client application was window forms and there was a refresh button that would call this method of the service.

but now, the client has asked for MVC3 as client application and want a page that calls this method every second.

can someone please help me understand how controller class logic would be implemented that would call this wcf service method every second and update the view?

thank you

  • 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-26T15:14:53+00:00Added an answer on May 26, 2026 at 3:14 pm

    If your point is to display the result in the html without reloading the page then,
    I think, you have to look at the cocept of reverse ajax or comet.

    I might suggest you a pseudocode here

    //javascript side
    function DoRequest() {
        $.post('/myController/Action',
          {},
          function(data) {
              if (data.HasNewMail) {
                  //do processing
              }
              DoRequest();
          },
          "json");
    }
    

    and controller side

    public class myController : Controller {
        public ActionResult Action(){
            DateTime startTime = DateTime.Now;
            DateTime endTime = startTime.AddMinutes(5);
            while (true) {
                var mails = CheckForMails();
                if (mails.Count() >0) {
                    return Json(new {HasNewMail = true; Mails= mails});
                }
                if (DateTime.Now > endTime) {
                    return Json(new {HasNewMail = false});
                }
                //wait one second then try again.
                Thread.Sleep(1000);
            }
        }
    }
    

    This is the most primitive implementation. You make a request to your action and your request is not returned immediately but held. Action starts checking mails each second. As it finds anyting to return it releases the request to the client. In javascript you make appropriate DOM updates and send the request again. If nothing is found during those 5 minutes response is returned indicating that there is no mails.

    Further you may refer to the following link Websync or look at connecting to the wcf service directly via silverlight here

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

Sidebar

Related Questions

I created a WCF service that has a method which makes a call to
I created a WCF service that exposed a method that has one paramater: public
I created a WCF service that uses TagLib# ( http://developer.novell.com/wiki/index.php/TagLib_Sharp ) which relies on
I recently created a WCF service that works fine when tested from Visual Studio
I created a WCF service (.NET 3.5) that grabs data from a db and
I created a simple wcf service that exposes a GetData method. It's actually the
We have created a WCF service hosted in a windows service that handles Authentication
I've created a .NET WCF service that is intended to always be over HTTPS.
I'm creating a WCF service that transfers entity objects created via entity framework. I
I have created a basic WCF service in IIS. I am aware that this

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.