The leading provider of version control solution and TWAIN SDK
The leading provider of version control solution and TWAIN SDK

Dynamsoft Forums

Support for Version Control, Bug Tracking and Configuration Management Software
* Login   * Register
* FAQ    * Search

It is currently Wed May 16, 2012 5:47 pm




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Automation: Working with IVSS using multiple STA threads
PostPosted: Sun Nov 21, 2010 7:46 am 
Offline

Joined: Sun Nov 21, 2010 7:26 am
Posts: 3
Hi,

Is it possible to work with VSS databases simultaneously via multiple STA threads?

Ex: Can I run two STA threads that would instantiate their own IVSSDatabase instances (on each thread) which will connect to two different VSS databases and try to get the latest vesrion of their contents in parallel?

Some tests I did on a processor with two cores suggest that above is not possible and VSS seem to be serializing the calls to the databases.

My Dev environment
Processor : Intel Core i3-330M (3M Cache, 2.13 GHz)
OS : Windows 7, 64 bit
Dev Env : Microsoft .NET framework 3.5 Sp1
VSS interop : Microsoft.VisualStudio.SourceSafe.Interop, Version 5.2.0.0 (VSS 2005)

Coder 97


Top
 Profile  
 
 Post subject: Re: Automation: Working with IVSS using multiple STA threads
PostPosted: Mon Nov 22, 2010 2:56 am 
Offline
User avatar

Joined: Tue Mar 08, 2005 12:23 am
Posts: 1489
Hi Coder97,

Quote:
Some tests I did on a processor with two cores suggest that above is not possible and VSS seem to be serializing the calls to the databases.


I think it's possible to work with multiple databases in parallel via parallel STA threads. To pinpoint the cause of the issue, would you please paste your test code here?


Regards.

_________________
Catherine Sea
Dynamsoft Support Team
Dynamsoft - The leading provider of version control solution and TWAIN SDK
Source Control Software | Software Configuration Management | SCM Solution | Issue Tracking
SourceSafe (VSS) Remote/Web/Internet Access | SourceSafe (VSS) Replacement/Alternative | SourceSafe (VSS) Hosting|TFS Hosting

Follow me @Twitter, Facebook
Image


Top
 Profile  
 
 Post subject: Re: Automation: Working with IVSS using multiple STA threads
PostPosted: Mon Nov 22, 2010 8:35 am 
Offline

Joined: Sun Nov 21, 2010 7:26 am
Posts: 3
Hi Catherine,

Here's the code I used.

Notes;
a. vssDB1 and vssDB2 both are two separate but identical databases to be able to compare the load on the threads.
b. Both VSS databases are sitting on the same drive (even if they were in two different drives it didnt make any difference)
c. I had to run this a couple of times to before I could notice that the thread T2 is really starting its jopb after the thread
T1 completes its job.
ie. Results of the first run was somewhat odd but the test runs 2nd, 3rd, ..... 10th produced pretty much the same results and was consistent.

Code:
using System;
using System.Text;
using Microsoft.VisualStudio.SourceSafe.Interop;
using System.IO;
using System.Threading;

namespace Post
{
    public class VSSTest
    {
        [STAThread]
        public static void Main(string[] args)
        {
            Thread.CurrentThread.Name = "Main";

            // Setup database login info...
            VSSDBLogin vssDB1 = new VSSDBLogin(@"G:\VSSDB1\srcsafe.ini", "Admin", null);
            VSSDBLogin vssDB2 = new VSSDBLogin(@"G:\VSSDB2\srcsafe.ini", "Admin", null);
           
            // Get the latest version of two VSS databases sequentially
            Console.WriteLine("Accessing databases sequentially.......");
           
            GetVSSLatestVersion(vssDB1);
           
            GetVSSLatestVersion(vssDB2);

            //---------------------------------------------------------------------------------------------//
                       
            // Get the same two VSS databases in parallel via two STA threads
            Console.WriteLine(Environment.NewLine + "Accessing databases in parallel.......");
           
            Thread t1 = new Thread(GetVSSLatestVersion);
            t1.SetApartmentState(ApartmentState.STA);
            t1.Name = "T1";

            Thread t2 = new Thread(GetVSSLatestVersion);
            t2.SetApartmentState(ApartmentState.STA);
            t2.Name = "T2";

            t1.Start(vssDB1);
            t2.Start(vssDB2);

            Console.ReadLine();
        }

        public static void GetVSSLatestVersion(object tvssDBLoginInfo)
        {
            VSSDBLogin vssDBLoginInfo = (VSSDBLogin) tvssDBLoginInfo;

            // Record start time...
            Console.WriteLine("Thread = {0}, Database = {1}, Job Started at {2}", Thread.CurrentThread.Name, vssDBLoginInfo.SrcSafeIni, DateTime.Now);

            DateTime sequentialCommonStart = DateTime.Now;

            // Record the actual DB open time...
            VSSDatabase vssDB = new VSSDatabase();
            vssDB.Open(vssDBLoginInfo.SrcSafeIni, vssDBLoginInfo.UserName, vssDBLoginInfo.Password);

            Console.WriteLine("Thread = {0}, Database Opened at {1}", Thread.CurrentThread.Name, DateTime.Now.ToString ());

            string targetFolder = Path.Combine(@"G:\VSSMT\", Path.GetFileNameWithoutExtension(Path.GetRandomFileName()));
            vssDB.get_VSSItem("$/", false).Get(ref targetFolder, (int)VSSFlags.VSSFLAG_RECURSYES);
            vssDB.Close();

            // Record the end time and the duration...
            DateTime sequentialCommonEnd = DateTime.Now;
            Console.WriteLine("Thread = {0}, Time taken = {1} s, Job Ended At = {2}", Thread.CurrentThread.Name,  sequentialCommonEnd.Subtract(sequentialCommonStart).TotalSeconds, DateTime.Now);
        }
    }

    public class VSSDBLogin
    {
        public VSSDBLogin(string tsrcSafeIni, string tuserName, string tpassword)
        {
            SrcSafeIni = tsrcSafeIni;
            UserName = tuserName;
            Password = tpassword;

        }

        public string SrcSafeIni
        {
            get;
            set;
        }

        public string UserName
        {
            get;
            set;
        }

        public string Password
        {
            get;
            set;
        }
    }
}


Top
 Profile  
 
 Post subject: Re: Automation: Working with IVSS using multiple STA threads
PostPosted: Tue Nov 23, 2010 5:59 pm 
Offline
User avatar

Joined: Tue Mar 08, 2005 12:23 am
Posts: 1489
Hi Coder97,

Sorry for the delay.

I don't find anything wrong with your test code. Also, I ran your code many times on my side but got the same results as you mentioned above. :? But technically, it should be possible to work with VSS databases simultaneously via multiple STA threads.

I will keep testing the issue on my side. If I find anything new, I'll let you know.

Regards.

_________________
Catherine Sea
Dynamsoft Support Team
Dynamsoft - The leading provider of version control solution and TWAIN SDK
Source Control Software | Software Configuration Management | SCM Solution | Issue Tracking
SourceSafe (VSS) Remote/Web/Internet Access | SourceSafe (VSS) Replacement/Alternative | SourceSafe (VSS) Hosting|TFS Hosting

Follow me @Twitter, Facebook
Image


Top
 Profile  
 
 Post subject: Re: Automation: Working with IVSS using multiple STA threads
PostPosted: Tue Nov 23, 2010 8:44 pm 
Offline

Joined: Sun Nov 21, 2010 7:26 am
Posts: 3
Hi Catherine,

Thanks for your assistance.

Yes please, let me know if you come accross anything on this issue.

Regards,

Coder 97


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

It is currently Wed May 16, 2012 5:47 pm


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

Copyright © 2010 Dynamsoft Corporation. All Rights Reserved. | Knowledge Base | Source Control Blog