Austin9675
Timer issue
Can anyone help me find out why my timer is decreasing by 2 instead of 1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PowerOps
{
public partial class SystemShutDown : Form
{
int timeLeft;
bool timerRunning = false;
public SystemShutDown()
{
InitializeComponent();
shutDown.Interval = 1000;
shutDown.Tick += shutDown_Tick;
}
private void shutDown_Tick(object sender, EventArgs e)
{
timer(sender, e);
}
public void timer(object sender, EventArgs e)
{
if (timeLeft > 0)
{
timeLeft--;
timerTextLabel.Text = $"Time Left: {timeLeft / 60:D2} minutes {timeLeft % 60:D2} seconds";
}
else
{
MessageBox.Show("Time's up!", "Countdown Complete");
timerRunning = false;
shutDown.Stop();
}
}
public void startButton_Click(object sender, EventArgs e)
{
if (!timerRunning)
{
int countDown = int.Parse(timerBox.Text) * 60;
timeLeft = countDown;
timerTextLabel.Text = $"Time Left: {timeLeft / 60:D2}:{timeLeft % 60:D2}";
shutDown.Interval = 1000;
shutDown.Start();
timerRunning = true;
}
}
} }
} }
1 replies
Finding a game file
I am making a UI for setting up a dedicated server for a game on steam, the problem im having is that the program can find the directory that the file is in but it cannot find the file it needs to write to, its a configuration file if that matters at all, so im basically wondering if theres anything special i need to do
2 replies
Recommendations
I have learned the basics of c# but thats literally all i know how to do, i want to get into some other things like learning to use system IO and being able to make useful programs, basically what im asking for is a list of websites or anything really that you may have learned off of and someone like myself can read and learn off of to expand my C# knowledge
5 replies