What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

What does "thread safe" mean?

JohnJohns

New Member
Joined
Jun 19, 2012
Messages
4
Reaction score
0
In a few forum threads (for the plugins: Unstucker and NotificationOKClick) some users posted that DemonBuddy is not thread safe. I could not find more information using the forum search for "thread safe".

What does that mean in terms of security? Should I not be using certain plugins as they have a risk of being detected by Warden?

Thanks.
 
It has nothing to do with security in the way you understand it.

It means in the software development, that a programm, what uses "threads" has to be sure, not to change data, while other threads using this.

I.E. one thread computes 4 + 2 and saves it in a variable called x, another thread does 5 + 2 and saves it in the same variable x. So thread 2 overwrites the result from thread one. Its a very simple example but i hope it clears it up for you.

Greetings
 
Hey JohnJohns. Just a bit of quick info for you. "thread safe" has nothing to do with "account security".

"http://blogs.msdn.com/b/ericlippert/archive/2009/10/19/what-is-this-thing-you-call-thread-safe.aspx" is an amazing read if you want to know exactly what this means! :D

Hope this helps out bro.
 
The most import info: reading in most cases is safe.
Writing is not safe.
Code:
//old school
static object LOCK = new object();
lock(LOCK)
{
//write to memory
}
 
So basically not being "thread-safe" is just another way of saying it isn't(/can't be) synchronized?
 
TO put it simply if DB is calling OnPulse by Invoking a delegate it should be safe enough, but the plugin writer has to ensure the code they write is safe.

i.e. buddyMain.BeginInvoke(Iplugin.OnPulse, new object[]{}); //that should prevent the plugin blocking DB, no idea what is done in DB however, but if the code in a plugin is safe then there is really nothing to worry about.

Unstucker needs to use the Bot Start/Stop WorldIsLoading Game Start/Stop events instead of a thread, but idk if those work yet fully
 
TO put it simply if DB is calling OnPulse by Invoking a delegate it should be safe enough, but the plugin writer has to ensure the code they write is safe.

i.e. buddyMain.BeginInvoke(Iplugin.OnPulse, new object[]{}); //that should prevent the plugin blocking DB, no idea what is done in DB however, but if the code in a plugin is safe then there is really nothing to worry about.

Unstucker needs to use the Bot Start/Stop WorldIsLoading Game Start/Stop events instead of a thread, but idk if those work yet fully

Unstucker doesn't use a thread. It does however use Thread.Sleep as a means of pausing the bot in the OnPulse() function which is only called when in game.
 
Unstucker doesn't use a thread. It does however use Thread.Sleep as a means of pausing the bot in the OnPulse() function which is only called when in game.

Out of context my comment makes no sense; I was working on a version that used a thread monitor to reset the vector collection. Works fine, but can cause a hang.

I added this it reloads a profile by using a swap file

Code:
        public void ReloadRestart()
        {
            ZetaDia.Service.Games.LeaveGame();
            System.Threading.Thread.Sleep(12000);
            BotMain.Stop();
            #region save tmp file
            string fp = [B]Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments)[/B] + "\\BWTmp.xml";
            System.IO.Stream s = null;
            System.IO.StreamWriter w = null;

            try
            {
                try
                {
                    if (System.IO.File.Exists(fp))
                    {
                        System.IO.File.Delete(fp);
                    }
                }
                catch (Exception failed) { Logging.Write(LogLevel.Verbose, "Error: " + failed.Message); }

                s = System.IO.File.Open(fp, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, System.IO.FileShare.Read);
                w = new System.IO.StreamWriter(s);
                lock (this)
                {
                    w.Write(reloadProfileXml.Text);
                }

            }
            catch (Exception ex)
            {
                Logging.Write("Error: " + ex.Message);
            }
            finally
            {
                if (null != w)
                {
                    w.Close();
                    w.Dispose();
                    w = null;
                }

                if (null != s)
                {
                    s.Close();
                    s.Dispose();
                    s = null;
                }
            }
            #endregion
            Zeta.CommonBot.ProfileManager.Load([B]Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments)[/B] + "\\BWTmp.xml");
            BotMain.Start();
        }
 
Out of context my comment makes no sense; I was working on a version that used a thread monitor to reset the vector collection. Works fine, but can cause a hang.

I added this it reloads a profile by using a swap file

Code:
        public void ReloadRestart()
        {
            ZetaDia.Service.Games.LeaveGame();
            System.Threading.Thread.Sleep(12000);
            BotMain.Stop();
            #region save tmp file
            string fp = [B]Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments)[/B] + "\\BWTmp.xml";
            System.IO.Stream s = null;
            System.IO.StreamWriter w = null;

            try
            {
                try
                {
                    if (System.IO.File.Exists(fp))
                    {
                        System.IO.File.Delete(fp);
                    }
                }
                catch (Exception failed) { Logging.Write(LogLevel.Verbose, "Error: " + failed.Message); }

                s = System.IO.File.Open(fp, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write, System.IO.FileShare.Read);
                w = new System.IO.StreamWriter(s);
                lock (this)
                {
                    w.Write(reloadProfileXml.Text);
                }

            }
            catch (Exception ex)
            {
                Logging.Write("Error: " + ex.Message);
            }
            finally
            {
                if (null != w)
                {
                    w.Close();
                    w.Dispose();
                    w = null;
                }

                if (null != s)
                {
                    s.Close();
                    s.Dispose();
                    s = null;
                }
            }
            #endregion
            Zeta.CommonBot.ProfileManager.Load([B]Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments)[/B] + "\\BWTmp.xml");
            BotMain.Start();
        }

Hmmm interesting. Where are you getting reloadProfileXml?
 
Last edited:
Hmmm interesting. Where are you getting reloadProfileXml?
in a text box, have you used my plugin? I actually had your unstucker concept full in there the other day but didn't see any reason to do something already being done
 
Back
Top