none
The type or namespace 'Semaphore Slim could not be found RRS feed

  • Question

  • Having similar issue to this

    http://stackoverflow.com/questions/15658318/using-semaphore-in-c-sharp

    I have determined that I have .NET 4.6.4 Preview or greater on my machine.

    So what gives?
    My understanding is that System.Threading contains the SempahoreSlim class.

    I am using source code from this example
    https://www.codeproject.com/articles/488668/csharp-tcp-server

    Just a partial code listing (first 50 lines of TcpServer)

       
    using System;    
    using System.Collections.Generic;    
    using System.ComponentModel;    
    using System.Net;    
    using System.Net.Sockets;    
    using System.Text;    
    using System.Threading;        
    namespace tcpServer    {        
    
    public delegate void tcpServerConnectionChanged(TcpServerConnection connection);        
    
    public delegate void tcpServerError(TcpServer server, Exception e);            
    
    public partial class TcpServer : Component        {            
    
    private List<TcpServerConnection> connections;            
    
    private TcpListener listener;                
    private Thread listenThread;            
    private Thread sendThread;                
    private bool m_isOpen;                
    private int m_port;            
    private int m_maxSendAttempts;            
    private int m_idleTime;            
    private int m_maxCallbackThreads;            
    private int m_verifyConnectionInterval;            private Encoding m_encoding;
                    
    private SemaphoreSlim sem;
                
    private bool waiting;

    Wednesday, February 1, 2017 9:12 PM

All replies

  • Forgot to add this is a Unity C# project!

    If I open the source project in VS I don't see the error and project properties shows I am targeting .Net framework 4. So I guess my question is more to do with the way Unity handles .net classes. Confused whether I should be trying to fix this WITHIN VS in the Solution explorer or...?

    Wednesday, February 1, 2017 9:31 PM
  • You mean Unity3D? Doesn't that target the Mono version of .NET?

    I believe that is still behind the latest .NET version, possibly the equivalent of .Net 3, which means that unfortunately you won't have any .Net 4 specific classes (such as SemaphoreSlim)

    • Proposed as answer by Kristin Xie Tuesday, February 14, 2017 2:41 AM
    Thursday, February 2, 2017 7:57 AM