Remove warnings regarding possible references to NULL
This commit is contained in:
@ -40,7 +40,14 @@ namespace Tidstagning
|
||||
{
|
||||
get
|
||||
{
|
||||
return Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
if (Assembly.GetExecutingAssembly().GetName().Version != null)
|
||||
{
|
||||
return Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return "N/A";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ namespace Tidstagning
|
||||
{
|
||||
InitializeComponent();
|
||||
System.IO.StreamReader deltager_handle = new System.IO.StreamReader(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Tidstagning/" + "Deltager.txt");
|
||||
string deltager;
|
||||
string? deltager;
|
||||
while ((deltager = deltager_handle.ReadLine()) != null)
|
||||
{
|
||||
string[] dele = deltager.Split(',');
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
using System.Threading;
|
||||
namespace Tidstagning
|
||||
{
|
||||
class Procedure
|
||||
@ -11,7 +11,7 @@ namespace Tidstagning
|
||||
List<DateTime> signaler;
|
||||
uint signalLength = 500;
|
||||
|
||||
System.Threading.Timer? timer;
|
||||
Timer? delayTimer;
|
||||
Int16 idx = 0;
|
||||
|
||||
public Procedure()
|
||||
@ -22,7 +22,7 @@ namespace Tidstagning
|
||||
public void ReadFile(string file)
|
||||
{
|
||||
System.IO.StreamReader procedure_handle = new System.IO.StreamReader(file);
|
||||
string line;
|
||||
string? line;
|
||||
while ((line = procedure_handle.ReadLine()) != null)
|
||||
{
|
||||
addEntry(line);
|
||||
@ -76,8 +76,8 @@ namespace Tidstagning
|
||||
{
|
||||
signaler = new List<DateTime>();
|
||||
idx = 0;
|
||||
if (timer != null)
|
||||
timer.Dispose();
|
||||
if (delayTimer != null)
|
||||
delayTimer.Dispose();
|
||||
}
|
||||
|
||||
public void setObjects(Relay horn_obj, ResultList log_obj)
|
||||
@ -114,18 +114,22 @@ namespace Tidstagning
|
||||
Run();
|
||||
return;//time already passed
|
||||
}
|
||||
log.Write("Næste signal: " + alertTime.ToString(@"HH\:mm\:ss") + " Om: " + timeToGo.ToString(@"hh\:mm\:ss"));
|
||||
timer = new System.Threading.Timer(x =>
|
||||
if (log is not null)
|
||||
{
|
||||
this.Alarm();
|
||||
}, null, timeToGo, new System.TimeSpan(0));
|
||||
log.Write("Næste signal: " + alertTime.ToString(@"HH\:mm\:ss") + " Om: " + timeToGo.ToString(@"hh\:mm\:ss"));
|
||||
}
|
||||
delayTimer = new Timer(x =>
|
||||
{
|
||||
this.Alarm();
|
||||
}, null, timeToGo, new TimeSpan(0));
|
||||
}
|
||||
|
||||
private void Alarm()
|
||||
{
|
||||
log.Write("HORN!");
|
||||
|
||||
horn.Sound(signalLength);
|
||||
if(log is not null)
|
||||
log.Write("HORN!");
|
||||
if(horn is not null)
|
||||
horn.Sound(signalLength);
|
||||
next();
|
||||
Run();
|
||||
|
||||
|
@ -9,7 +9,6 @@ namespace Tidstagning
|
||||
class Relay
|
||||
{
|
||||
SerialPort com;
|
||||
System.Threading.Timer? cooldownTimer;
|
||||
|
||||
struct SignalSpec
|
||||
{
|
||||
@ -89,7 +88,7 @@ namespace Tidstagning
|
||||
Off();
|
||||
}
|
||||
|
||||
cooldownTimer = new System.Threading.Timer(x =>
|
||||
System.Threading.Timer cooldownTimer = new System.Threading.Timer(x =>
|
||||
{
|
||||
signals.Dequeue();
|
||||
Run();
|
||||
|
@ -4,16 +4,15 @@ namespace Tidstagning
|
||||
{
|
||||
class ResultList
|
||||
{
|
||||
|
||||
System.IO.StreamWriter filehandle;
|
||||
System.IO.StreamWriter filehandle2;
|
||||
System.IO.StreamWriter filehandle_log;
|
||||
System.IO.StreamWriter filehandle_results;
|
||||
Tidstagning.MainUI parentForm;
|
||||
string racenumber = "";
|
||||
public ResultList(string filename, Tidstagning.MainUI log_object)
|
||||
{
|
||||
filename = MakeSafeFilename(filename, '_');
|
||||
filehandle = new System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Tidstagning/" + filename + "_" + DateTime.Now.ToString(" dd-MM-yyyy HH-mm-ss") + ".txt");
|
||||
filehandle2 = new System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Tidstagning/" + filename + "_" + DateTime.Now.ToString(" dd-MM-yyyy HH-mm-ss") + ".csv");
|
||||
filehandle_log = new System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Tidstagning/" + filename + "_" + DateTime.Now.ToString(" dd-MM-yyyy HH-mm-ss") + ".txt");
|
||||
filehandle_results = new System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/Tidstagning/" + filename + "_" + DateTime.Now.ToString(" dd-MM-yyyy HH-mm-ss") + ".csv");
|
||||
parentForm = log_object;
|
||||
}
|
||||
|
||||
@ -58,21 +57,21 @@ namespace Tidstagning
|
||||
|
||||
public void Write(string textstring)
|
||||
{
|
||||
filehandle.WriteLine(textstring);
|
||||
filehandle_log.WriteLine(textstring);
|
||||
parentForm.LogAppend(textstring + "\r\n");
|
||||
filehandle.Flush();
|
||||
filehandle_log.Flush();
|
||||
}
|
||||
|
||||
public void WriteCSV(string textstring)
|
||||
{
|
||||
filehandle2.WriteLine(textstring);
|
||||
filehandle2.Flush();
|
||||
filehandle_results.WriteLine(textstring);
|
||||
filehandle_results.Flush();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
filehandle.Close();
|
||||
filehandle2.Close();
|
||||
filehandle_log.Close();
|
||||
filehandle_results.Close();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user