TPL - Using static method vs struct method
<p>I have about 1500 files on a share for which I need to collect FileVersionInfo string. So I created a Static method in my Gateway like this:</p>

<pre><code>private static string GetVersionInfo(string filepath)
{
    FileVersionInfo verInfo = FileVersionInfo.GetVersionInfo(filepath);
    return string.Format("{0}.{1}.{2}.{3}", verInfo.ProductMajorPart, verInfo.ProductMinorPart,
                                            verInfo.ProductBuildPart, verInfo.ProductPrivatePart).Trim();
}
</code></pre>

<p>And then used FileAndVersion struct in a PLINQ call with DegreeOfParallelism as this is I/O related</p>

<pre><code>resultList = dllFilesRows.AsParallel().WithDegreeOfParallelism(20)
                    .Select(r =&gt;
                    {
                        var symbolPath = r.Filename;
                        return new FilenameAndVersion{Filename=symbolPath, Version=GetVersionInfo(symbolPath)};
                    })
                    .ToArray();
</code></pre>

<p>Later I modified the Struct, FileAndVersion as:</p>

<pre><code> private struct FilenameAndVersion 
{
    private string _version, _filename;
    public string Version { get { return _version; } }
    public string Filename { get { return _filename; } }

    private void SetVersion()
    {
        FileVersionInfo verInfo = FileVersionInfo.GetVersionInfo(this.Filename);
        this._version = string.Format("{0}.{1}.{2}.{3}", verInfo.ProductMajorPart, verInfo.ProductMinorPart,

                                                                                    verInfo.ProductBuildPart, verInfo.ProductPrivatePart).Trim();
}
public FilenameAndVersion(string filename, string version)
{
    this._filename = filename;
    this._version = string.Empty;
    SetVersion();
}
</code></pre>

<p>}           </p>

<p>And used it:</p>

<pre><code>resultList = dllFilesRows.AsParallel().WithDegreeOfParallelism(20)
                    .Select(r =&gt;
                    {
                        var symbolPath = r.Filename;
                        return new FilenameAndVersion(symbolPath, String.Empty);
                    })
                    .ToArray();
</code></pre>

<p>The question is, is this going to help me in anyway and is a good pattern to use ? 
Forgot to mention that the files are on a server that has RAID 10 with SAN attached to it.</p>

<p>Sunit</p>
