草庐IT

TASK_TYPE

全部标签

c# - 使用 Task.Factory.StartNew 传递方法参数

我有以下代码:vartask=Task.Factory.StartNew(CheckFiles,cancelCheckFile.Token,TaskCreationOptions.LongRunning,TaskScheduler.Default);privatevoidCheckFiles(){//Dostuff}我现在想修改CheckFiles以接受整数和BlockingCollection引用privatevoidCheckFiles(intInputID,BlockingCollectionBlockingDataCollection){//Dostuff}我似乎无法像上面那样

c# - 无法从 Task<> 隐式转换类型

我正在尝试掌握.NET4.5中的异步方法语法。我以为我已经完全理解了这些示例,但是无论异步方法的类型是什么(即Task),我总是在转换回T时得到相同类型的错误错误。-我知道这几乎是自动的。以下代码产生错误:Cannotimplicitlyconverttype'System.Threading.Tasks.Task>'to'System.Collections.Generic.List'publicListTestGetMethod(){returnGetIdList();//compilererroronthisline}asyncTask>GetIdList(){using(Htt

c# - 无法从 Task<> 隐式转换类型

我正在尝试掌握.NET4.5中的异步方法语法。我以为我已经完全理解了这些示例,但是无论异步方法的类型是什么(即Task),我总是在转换回T时得到相同类型的错误错误。-我知道这几乎是自动的。以下代码产生错误:Cannotimplicitlyconverttype'System.Threading.Tasks.Task>'to'System.Collections.Generic.List'publicListTestGetMethod(){returnGetIdList();//compilererroronthisline}asyncTask>GetIdList(){using(Htt

c# - WCF 服务客户端 : The content type text/html; charset=utf-8 of the response message does not match the content type of the binding

我在我的本地IIS服务器上运行了一个WCF服务。我已将它添加为C#网站项目的服务引用,它添加得很好并自动生成代理类。但是,当我尝试调用任何服务契约(Contract)时,出现以下错误:描述当前网络请求的执行。请查看堆栈跟踪以获取更多信息有关错误及其位置的信息它起源于代码。异常详细信息:System.ServiceModel.ProtocolException:内容类型text/html;响应消息的charset=utf-8不匹配的内容类型绑定(bind)(应用程序/soap+xml;字符集=utf-8)。如果使用自定义编码器,请确保IsContentTypeSupported方法是实现

c# - WCF 服务客户端 : The content type text/html; charset=utf-8 of the response message does not match the content type of the binding

我在我的本地IIS服务器上运行了一个WCF服务。我已将它添加为C#网站项目的服务引用,它添加得很好并自动生成代理类。但是,当我尝试调用任何服务契约(Contract)时,出现以下错误:描述当前网络请求的执行。请查看堆栈跟踪以获取更多信息有关错误及其位置的信息它起源于代码。异常详细信息:System.ServiceModel.ProtocolException:内容类型text/html;响应消息的charset=utf-8不匹配的内容类型绑定(bind)(应用程序/soap+xml;字符集=utf-8)。如果使用自定义编码器,请确保IsContentTypeSupported方法是实现

c# - 类映射错误 : 'T' must be a non-abstract type with a public parameterless constructor

虽然映射类出现错误“T”必须是具有公共(public)无参数构造函数的非抽象类型,以便将其用作泛型类型或方法中的参数“T”。下面是我的SqlReaderBase类publicabstractclassSqlReaderBase:ConnectionProvider{#regionAbstractMethodsprotectedabstractstringcommandText{get;}protectedabstractCommandTypecommandType{get;}protectedabstractCollectionGetParameters(IDbCommandcomma

c# - 类映射错误 : 'T' must be a non-abstract type with a public parameterless constructor

虽然映射类出现错误“T”必须是具有公共(public)无参数构造函数的非抽象类型,以便将其用作泛型类型或方法中的参数“T”。下面是我的SqlReaderBase类publicabstractclassSqlReaderBase:ConnectionProvider{#regionAbstractMethodsprotectedabstractstringcommandText{get;}protectedabstractCommandTypecommandType{get;}protectedabstractCollectionGetParameters(IDbCommandcomma

c# - "await Task.Run(); return;"和 "return Task.Run()"之间有什么区别吗?

这个问题在这里已经有了答案:Whyuseasyncandreturnawait,whenyoucanreturnTaskdirectly?(8个答案)关闭3个月前。下面两段代码在概念上有区别吗:asyncTaskTestAsync(){awaitTask.Run(()=>DoSomeWork());}和TaskTestAsync(){returnTask.Run(()=>DoSomeWork());}生成的代码是否也不同?编辑:为避免与Task.Run混淆,类似情况:asyncTaskTestAsync(){awaitTask.Delay(1000);}和TaskTestAsync()

c# - "await Task.Run(); return;"和 "return Task.Run()"之间有什么区别吗?

这个问题在这里已经有了答案:Whyuseasyncandreturnawait,whenyoucanreturnTaskdirectly?(8个答案)关闭3个月前。下面两段代码在概念上有区别吗:asyncTaskTestAsync(){awaitTask.Run(()=>DoSomeWork());}和TaskTestAsync(){returnTask.Run(()=>DoSomeWork());}生成的代码是否也不同?编辑:为避免与Task.Run混淆,类似情况:asyncTaskTestAsync(){awaitTask.Delay(1000);}和TaskTestAsync()

c# - Linq Query 一直抛出 "Unable to create a constant value of type System.Object....",为什么?

以下是代码示例:privatevoidloadCustomer(intcustIdToQuery){vardbContext=newSampleDB();try{varcustomerContext=fromtindbContext.tblCustomers//keepsthrowing:wheret.CustID.Equals(custIdToQuery)//Unabletocreateaconstantvalueoftype'System.Object'.selectnew//Onlyprimitivetypes('suchasInt32,String,andGuid'){//ar