I am new to c# and I am trying to figure out what am I doing wrong in the following script. I am getting an error "Method Name Expected" when starting a new Thread for the "del" delegate. The method getUrlThread is clearly defined and the delegate del is pointing to it so why is it not being seen? Thank you.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.IO;
using System.Threading;
namespace updateNewFrontEnd
{
public partial class frmMain : Form
{
public frmMain()
{
InitializeComponent();
}
// define function pointer
// =======================
public delegate string getUrlThreadDelegate(string targetUrl);
// define function for the function pointer
// ========================================
public string getUrlThread(string targetUrl)
{
httpRequestClass urlResponseText = new httpRequestClass();
urlResponseText.TargetUrl = targetUrl;
string text = urlResponseText.getUrlResponse();
return text;
}
private void btnUrl_Click(object sender, EventArgs e)
{
// top decalrations
// ================
.... some code here....
string targetUrl = "some string here...";
// instantiate the HTTP call object to the "targetUrl" url
// =======================================================
getUrlThreadDelegate del = new getUrlThreadDelegate(getUrlThread);
Thread t1 = new Thread(new ThreadStart(del(targetUrl))); // ERROR HERE !!!
t1.Start();
.... some more code here....
}
}
}