Click here to Skip to main content
15,920,110 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Orginal Code
public void HashTorrent(TorrentManager manager)
       {
           // Note: The manager must be in the 'Stopped' state in order to perform
           // a hash check. Also, to make the sample easier the event handler
            // is not unregistered. In your application be careful you don't
          // accidentally attach a new event handler every time the torrent is hashed
          manager.PieceHashed += delegate (object o, PieceHashedEventArgs e);
               int pieceIndex = e.PieceIndex;
               int totalPieces = e.TorrentManager.Torrent.Pieces.Count;
              double progress = (double) pieceIndex / totalPieces * 100.0;
             if (e.HashPassed)
                  Console.WriteLine("Piece {0} of {1} is complete", pieceIndex, totalPieces);
               else
                   Console.WriteLine("Piece {0} of {1} is corrupt or incomplete ", pieceIndex, totalPieces);

               // This shows how complete the hashing is.
               Console.WriteLine("Total progress is: {0}%", progress);

              // This shows the percentage completion of the download. This value
              // is updated as the torrent is hashed or new pieces are downloaded
               Console.WriteLine("{0}% of the torrent is complete");
          };

           // If 'true' is passed, the torrent will automatically go to the 'Downloading' or 'Seeding'
           // state once the hash check is finished. Otherwise it will return to the 'Stopped' state.
            manager.HashCheck(false);
    }


my problem is i cant convert this line to vb.net
manager.PieceHashed += delegate (object o, PieceHashedEventArgs e);
Posted
Updated 15-Oct-12 7:52am
v2
Comments
Sergey Alexandrovich Kryukov 15-Oct-12 11:30am    
Why would you ever translate this code in VB.NET?!
--SA
[no name] 15-Oct-12 11:33am    
You already posted this, received more than one answer and accepted a solution. So why are you reposting this again?

Here:
VB
manager.PieceHashed += Sub(o As Object, e As PieceHashedEventArgs)
    ' ...
End Sub

You cannot ask such questions every time you need to translate something. Here is the Web tool you can use:
http://www.developerfusion.com/tools/convert/csharp-to-vb/[^].

Besides — please see my comment to the question — I'm not sure such translation makes sense in all cases. Perhaps you simply should understand that you can freely mix up project written in different .NET languages in any .NET solution. You can just develop separate assemblies in different languages, especially if you want to use some available code, and then you can reference some assembly in some other assembly; this is the way to use a referenced assembly as a library.

—SA
 
Share this answer
 
Comments
Maciej Los 15-Oct-12 13:10pm    
Great answer, +5!
Sergey Alexandrovich Kryukov 15-Oct-12 13:19pm    
Thank you, Maciej.
--SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900