簡體   English   中英

C#| 類型或名稱空間ParamaterizedThreadStart不存在

[英]c# | the type or namespace ParamaterizedThreadStart does not exist

好的,所以本質上這正在發生:

我正在嘗試運行

Thread tcpHandlerThread = new ParamaterizedThreadStart(tcpHandler);

但我得到了錯誤

類型或名稱空間ParamaterizedThreadStart不存在

在ParamaterizedThreadStart上,但是我有這些導入:

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.Net.Sockets;
using System.IO;
using System.Threading;

如果這是一個愚蠢的問題,很抱歉:\\我缺少什么輸入,或者只是Visual Studio錯誤?

ParameterizedThreadStart是一個delegate

用這個代替。

Thread tcpHandlerThread = new Thread(tcpHandler);

如果要運行帶有參數的方法。 你可以用這個

Thread tcpHandlerThread = new Thread(() => tcpHandler(parameters));

看起來您對ParameterizedThreadStart類的拼寫錯誤。

下面的鏈接可能會對您有所幫助,並且有一個很好的示例說明如何創建參數化線程。

https://msdn.microsoft.com/zh-CN/library/1h2f2459%28v=vs.110%29.aspx

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM