KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have encountered this .NET compile time error, as shown below: 'Timer' is an ambiguous reference between 'System.Windows.Forms.Timer' and 'System.Threading.Timer' It occurred after I added this code block for a clock: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Net.Sockets; using System.Threading; using System.Security.Cryptography; namespace SocketClient { public partial class SocketClient : Form { System.Net.Sockets.TcpClient clientSocket = new System.Net.Sockets.TcpClient(); NetworkStream serverStream = default(NetworkStream); string readData = null; public SocketClient() { InitializeComponent(); Timer timer = new Timer(); timer.Tick += new EventHandler(TimerOnTick); timer.Interval = 1000; timer.Start(); } private void TimerOnTick(object sender, EventArgs ea) { Invalidate(); } protected override void OnPaint(PaintEventArgs pea) { StringFormat strfmt = new StringFormat(); strfmt.Alignment = StringAlignment.Far; strfmt.LineAlignment = StringAlignment.Far; pea.Graphics.DrawString(DateTime.Now.ToString("F"), Font, new SolidBrush(ForeColor), ClientRectangle, strfmt); } private void getMessage() { while (true) { serverStream = clientSocket.GetStream(); int buffSize = 0; byte[] inStream = new byte[10025]; buffSize = clientSocket.ReceiveBufferSize; serverStream.Read(inStream, 0, buffSize); string returndata = System.Text.Encoding.ASCII.GetString(inStream);
Tags (comma-separated)
Save Edits
Cancel