How can I create a DOTNET COM joint assembly for a classic ASP that does not block other threads?

Customization. Create a simple COM add-on via DOTNET / C # that does nothing but sleep in the current thread for 5 seconds.

namespace ComTest
{
    [ComVisible(true)]
    [ProgId("ComTester.Tester")]
    [Guid("D4D0BF9C-C169-4e5f-B28B-AFA194B29340")]
    [ClassInterface(ClassInterfaceType.AutoDual)]
    public class Tester 
    {
        [STAThread()]
        public string Test()
        {
            System.Threading.Thread.Sleep(5000); 
            return DateTime.Now.ToString();
        }

    }
}

On the ASP page, invoke the test component:

<%@ Language=VBScript %>
<%option explicit%>
<%response.Buffer=false%>

<%



 dim test
 set test = CreateObject("ComTester.Tester")


%>

 <HTML>
 <HEAD></HEAD>
 <BODY>
  <%
  Response.Write(test.Test())
  set test = nothing

  %>

 </BODY>
 </HTML>

When run on a Windows 2003 server, the test.asp page blocks ALL OTHER threads on the site while the COM components are sleeping.

How to create a COM component for ASP that does not block all ASP worker threads?

+3
source share
1 answer

I would say that here it is very likely that all web requests are serialized somewhere. It's hard to say exactly where this happens, but there are a couple of possibilities.

  • COM- - -. COM-, STA, , , , , . , Tester.Test.

  • ASP - . , ASP , , . , ASP.NET AspCompat, true, . , , STA COM.

0

Source: https://habr.com/ru/post/1745493/


All Articles