• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 378
  • Last Modified:

Compilation error trying to construct a Thread instance in JScript.Net

I have an ASPX page written in JScript.net that will do something and then start another thread do do some more stuff and return to the user. The thread will continue executing to complete its task (logging).

However, I am unable to create the thread in JScript.Net like I can in C# - it gets a compile error because the Thread constructor has 2 overloads that take a single argument and the compiler can not tell which one to use.

Here is a sample piece of code you can use to reproduce the compile error.

Gary Davis

<%@ Page Language="JScript" %>
	Small test case of compilation error on the first statement constructing the Thread instance.
	Error is:
		Description: An error occurred during the compilation of a resource required to service this request. 
				Please review the following specific error details and modify your source code appropriately. 
		Compiler Error Message: JS1184: More than one constructor matches this argument list
var t : System.Threading.Thread = new System.Threading.Thread(DoSend);
function DoSend(s : String) {
	var stURL : String = s;

Open in new window

Gary Davis
Gary Davis
  • 2
1 Solution
Check to see if there is anything on http://msdn2.microsoft.com/en-us/library/wdk85zxa(VS.71).aspx
that will help you understand what JS1184 means.

The resolution given is : Check the data types accepted by the overloaded constructor and make sure the data types of the arguments match only one overloaded constructor.
Gary DavisDir Internet SvcsAuthor Commented:
Yes, I saw that article and was not able to coerce the parameter such that the compiler error was resolved.
Gary DavisDir Internet SvcsAuthor Commented:
Well, with no solution, the best I could do was to change <% and %> to use <script runat="server"> and put the code in a Page_Load function (necessary for some reason).

Then, I dropped the idea of the separate thread and instead used a WebClient method that requests a web page asynchronously (that's the "something" I wanted to do in the thread). This did require the async="True" setting on the @Page statement.

Closed, 500 points refunded.
EE Moderator
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now