Timelocked.Cs Fixed

Status
Not open for further replies.

Ques

New Member
Nov 23, 2010
10
0
I Fixed Time Lock On My EMeu Works Perfectly Here It Is Enjoy Thank Me!


PHP:
using System;
using System.Threading;

// how to use.... set locks to:      use (TimedLock.Lock(obj))     obj = what your locking onto

#if DEBUG
public class TimedLock : IDisposable
#else
public struct TimedLock : IDisposable
#endif
{
    public static TimedLock Lock(object o)
    {
        return Lock(o, TimeSpan.FromSeconds(10)); // set time in seconds here
    }

    public static TimedLock Lock(object o, TimeSpan timeout)
    {
        TimedLock tl = new TimedLock(o);
        if (!Monitor.TryEnter(o, timeout))
        {
#if DEBUG
            System.GC.SuppressFinalize(tl);
#endif
            // throw the exception because the lock did not release properly...
            throw new LockTimeoutException();
        }

        return tl;
    }

    private TimedLock(object o)
    {
        target = o;
    }
    private object target;

    public void Dispose()
    {
        // exit the try monitor
        Monitor.Exit(target);

#if DEBUG
        GC.SuppressFinalize(this);
#endif
    }

#if DEBUG
    ~TimedLock()
    {
        System.Diagnostics.Debug.Fail("Lock was undisposed");
    }
#endif

}
public class LockTimeoutException : Exception
{
    public LockTimeoutException()
        : base("Timeout whilst waiting for lock")  // lock timed out...
    {
    }
}

Credits:
Scooter [Fixing]
 

Kryptos

prjRev.com
Jul 21, 2010
2,205
1,252
Did you actually do this yourself? I have friends that have done this, I can just ask them if it is a leech.
How many users does your hotel have?
You can't fix locks with a timelock.cs, Matty once explained it to me, I can't remember.

Thanks for the release anyways.
 

Ques

New Member
Nov 23, 2010
10
0
he didnt fix locks he just made so it can be more users and it holds 35+
 

Kryptos

prjRev.com
Jul 21, 2010
2,205
1,252
No, he named it TimedLock.cs, and it was to fix the locks not to 'so it can be more users', and 35+ is nothing, the locks doesn't make the server crash until 100+.
I recommend you google Locks, study them and attempt to fix them, or just delete them.
 
Status
Not open for further replies.

Users who are viewing this thread

Top