Click here to Skip to main content
15,913,941 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to remove rows of a DataTable based on checkboxes? Pin
Mycroft Holmes2-Apr-21 13:18
professionalMycroft Holmes2-Apr-21 13:18 
AnswerRe: How to remove rows of a DataTable based on checkboxes? Pin
Gerry Schmitz1-Apr-21 18:28
mveGerry Schmitz1-Apr-21 18:28 
GeneralRe: How to remove rows of a DataTable based on checkboxes? Pin
Alex Dunlop1-Apr-21 18:32
Alex Dunlop1-Apr-21 18:32 
GeneralRe: How to remove rows of a DataTable based on checkboxes? Pin
Gerry Schmitz1-Apr-21 19:39
mveGerry Schmitz1-Apr-21 19:39 
QuestionPartial View Question Pin
pkfox31-Mar-21 8:39
professionalpkfox31-Mar-21 8:39 
AnswerRe: Partial View Question Pin
Matthew Dennis31-Mar-21 11:04
sysadminMatthew Dennis31-Mar-21 11:04 
GeneralRe: Partial View Question Pin
pkfox31-Mar-21 21:13
professionalpkfox31-Mar-21 21:13 
QuestionHow autoconnect shapes in Canvas WPF Pin
Newbee_Mark30-Mar-21 23:54
Newbee_Mark30-Mar-21 23:54 
AnswerRe: How autoconnect shapes in Canvas WPF Pin
Gerry Schmitz31-Mar-21 7:33
mveGerry Schmitz31-Mar-21 7:33 
GeneralRe: How autoconnect shapes in Canvas WPF Pin
Newbee_Mark31-Mar-21 7:37
Newbee_Mark31-Mar-21 7:37 
GeneralRe: How autoconnect shapes in Canvas WPF Pin
Gerry Schmitz31-Mar-21 14:57
mveGerry Schmitz31-Mar-21 14:57 
GeneralRe: How autoconnect shapes in Canvas WPF Pin
Newbee_Mark31-Mar-21 23:40
Newbee_Mark31-Mar-21 23:40 
GeneralRe: How autoconnect shapes in Canvas WPF Pin
Gerry Schmitz1-Apr-21 6:24
mveGerry Schmitz1-Apr-21 6:24 
GeneralRe: How autoconnect shapes in Canvas WPF Pin
Newbee_Mark1-Apr-21 22:54
Newbee_Mark1-Apr-21 22:54 
QuestionList not printing out hardcoded books already added to list Pin
Member 1451443230-Mar-21 12:14
Member 1451443230-Mar-21 12:14 
AnswerRe: List not printing out hardcoded books already added to list Pin
Dave Kreskowiak30-Mar-21 14:03
mveDave Kreskowiak30-Mar-21 14:03 
GeneralRe: List not printing out hardcoded books already added to list Pin
Member 1451443231-Mar-21 10:27
Member 1451443231-Mar-21 10:27 
GeneralRe: List not printing out hardcoded books already added to list Pin
Dave Kreskowiak31-Mar-21 10:33
mveDave Kreskowiak31-Mar-21 10:33 
GeneralRe: List not printing out hardcoded books already added to list Pin
Member 1451443231-Mar-21 10:43
Member 1451443231-Mar-21 10:43 
QuestionHow to convert a column of DataTable into integer values? Pin
Alex Dunlop29-Mar-21 5:30
Alex Dunlop29-Mar-21 5:30 
AnswerRe: How to convert a column of DataTable into integer values? Pin
Richard Deeming29-Mar-21 5:42
mveRichard Deeming29-Mar-21 5:42 
AnswerRe: How to convert a column of DataTable into integer values? Pin
Mycroft Holmes29-Mar-21 20:21
professionalMycroft Holmes29-Mar-21 20:21 
AnswerRe: How to convert a column of DataTable into integer values? Pin
Arfat M1-Apr-21 19:58
Arfat M1-Apr-21 19:58 
GeneralRe: How to convert a column of DataTable into integer values? Pin
Richard Deeming6-Apr-21 0:06
mveRichard Deeming6-Apr-21 0:06 
GeneralChanging value in variable from another called class Pin
StealthRT28-Mar-21 17:26
StealthRT28-Mar-21 17:26 
Hey all I have been racking my brain trying to figure out what it is I am missing from the code below in order for the value "7:50 pm" to be placed into the variable theCntDownTimerTime from the TinyWS.cs class.

Let say the code below starts out with the time "7:00 pm".

I send the command from PostMAN (7:50 pm) and it picks it up just fine and the jsonSent.changeCNT does have the correct value of "7:50 pm". However, after this it seems to lose that value once the timer updates in the clockCoiuntDown.xaml.cs page for the theCntDownTimerTime.ToLower(). That value is still the same value (7:00 pm) as it was when the program started up and read my text file to get the default time.

clockCountDown.xaml.cs

C#
namespace laptopWatcher {  
  public partial class clockCountDown: Window {  
    public string theCntDownTimerTime = "";  
  
    public clockCountDown() {  
      InitializeComponent();  
      //get countdown time  
      theCntDownTimerTime = getTimeToStart();  
    }  
  
    private void Window_Loaded(object sender, RoutedEventArgs e) {  
      var desktopWorkingArea = SystemParameters.WorkArea;  
      this.Left = desktopWorkingArea.Right - this.Width - 20;  
      this.Top = desktopWorkingArea.Top + this.Height - 30;  
      var ts = ((60 - DateTime.Now.Second) * 1000 - DateTime.Now.Millisecond);  
  
      clockTimer.Tick += new EventHandler(clockTimer_tick);  
      clockTimer.Interval = new TimeSpan(0, 0, 35);  
      clockTimer.Start();  
  
      //Populate the time once to show to user  
      bgTxt.Text = DateTime.Now.ToString("h:mm tt");  
      txt.Text = DateTime.Now.ToString("h:mm tt");  
  
      //check if time for count down  
      if (txt.Text.ToLower().Equals(theCntDownTimerTime.ToLower())) {  
        _timer.Stop();  
        TimeSpan time = TimeSpan.Parse(theCntDownTimerTime);  
        cdownTimer((_time).TotalSeconds);  
      }  
  
      _tws = new TinyWS();  
      Thread t = new Thread(new ThreadStart(_tws.startWS));  
  
      t.Start();  
    }  
  
    private void clockTimer_tick(object sender, EventArgs e) {  
      bgTxt.Text = DateTime.Now.ToString("h:mm tt");  
      txt.Text = DateTime.Now.ToString("h:mm tt");  
      Console.WriteLine(txt.Text.ToLower() + " vs " + theCntDownTimerTime.ToLower());  
    }  
  
    public string getTimeToStart() {  
      string line;  
  
      using(StreamReader sr = new StreamReader(Environment.CurrentDirectory + "\\timestart.txt")) {  
        line = sr.ReadLine();  
      }  
  
      return line.ToLower();  
    }  
  
    // etc etc....  
  }  
}


TinyWS.cs

C#
namespace laptopLogin {  
  class TinyWS: clockCountDown {  
    HttpListener listener = new HttpListener();  
    clockCountDown ccd = new clockCountDown();  
  
    public class receivedData {  
      public string changeCNT {  
        get;  
        set;  
      }  
      public int timeAdd {  
        get;  
        set;  
      }  
      public bool internet {  
        get;  
        set;  
      }  
      public bool shutdownNow {  
        get;  
        set;  
      }  
    }  
  
    public void startWS() {  
      var prefixes = new List < string > () {  
        "http://*:8888/"  
      };  
  
      foreach(string s in prefixes) {  
        listener.Prefixes.Add(s);  
      }  
  
      listener.Start();  
      Console.WriteLine("Listening...");  
  
      while (true) {  
        HttpListenerContext context = listener.GetContext();  
        HttpListenerRequest request = context.Request;  
  
        string documentContents;  
  
        using(Stream receiveStream = request.InputStream) {  
          using(StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8)) {  
            documentContents = readStream.ReadToEnd();  
          }  
        }  
  
        Console.WriteLine($"Recived request for {request.Url}");  
        Console.WriteLine(documentContents);  
        HttpListenerResponse response = context.Response;  
  
        //Check out the response  
        receivedData jsonSent = JsonConvert.DeserializeObject < receivedData > (documentContents);  
  
        if (jsonSent.changeCNT.ToLower() != ccd.getTimeToStart()) {  
          //The default shutdown time has changed so update the txt file.  
          using(StreamWriter sw = new StreamWriter(Environment.CurrentDirectory + "\\timestart.txt", false)) {  
            sw.WriteLine(jsonSent.changeCNT);  
          }  
  
          ccd.theCntDownTimerTime = jsonSent.changeCNT;  
        }  
  
        //Reply  
        string responseString = "hit";  
        byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);  
        response.ContentLength64 = buffer.Length;  
        Stream output = response.OutputStream;  
        output.Write(buffer, 0, buffer.Length);  
        output.Close();  
      }  
    }  
  
    public void stopWS() {  
      listener.Stop();  
    }  
  }  
}  


So what would I be missing? It looks fine to me but just doesn't store the value over.

I also have tried:

C#
public string theCntDownTimerTime = "";  
public string _newCNT {  
  get {  
    return theCntDownTimerTime;  
  }  z
  set {  
    theCntDownTimerTime = value;  
  }  
}


And on the TinyWS.cs page I have it sending by like ccd._newCNT = jsonSent.changeCNT;

But that also does not hold the new value.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.