|
First, stop thinking in terms of "transferring". You'll do nothing of the sort.
When you populate the TreeView, you set the Tag property of the TreeViewItem to the full path to the file/folder.
In the button handler code, you get the currently selected item from the treeview, look at it's Tag property to get the full path of the item, then create a new ListViewItem with whatever data you want, making sure to again, put the full path in it's Tag property, add it to the ListView. Then you delete the selected item from the TreeView if you so desire.
|
|
|
|
|
hi all,
i use multi threading in my application which perform the work of downloading file.
the following code Create the thread & start them
<br />
Protected Sub DownloadFileInfo(ByVal sourcePath As String, ByVal DestinationPath As String)<br />
If Not File.Exists(DestinationPath) Then<br />
ReDim Preserve TotalThreads(TotalThreadCreated)<br />
'ReDim Preserve WaitAllDownloadEvent(TotalThreadCreated)<br />
Dim DownLoadObject As DownloadClass = New DownloadClass<br />
TotalThreads(TotalThreadCreated) = New Thread(AddressOf DownLoadObject.StartDownload)<br />
TotalThreads(TotalThreadCreated).Name = TotalThreadCreated.ToString<br />
TotalThreads(TotalThreadCreated).IsBackground = True<br />
'TotalThreads(TotalThreadCreated).<br />
'WaitAllDownloadEvent(TotalThreadCreated) = New AutoResetEvent(False)<br />
<br />
DownLoadObject.DownloadFileWithSourcePath1 = sourcePath<br />
DownLoadObject.DownloadFileWithDestinationPath1 = DestinationPath<br />
DownLoadObject.MyObjectNumber1 = TotalThreadCreated<br />
TotalThreads(TotalThreadCreated).Start()<br />
TotalThreadCreated += 1<br />
<br />
End If<br />
End Sub<br />
<br />
code of downloadClass is following
<br />
Imports system<br />
Imports System.Threading<br />
Imports System.IO<br />
<br />
Public Class DownloadClass<br />
Public DownloadFileWithSourcePath1 As String<br />
Public DownloadFileWithDestinationPath1 As String<br />
Public MyObjectNumber1 As Integer<br />
<br />
<br />
Sub StartDownload()<br />
If Not File.Exists(DownloadFileWithDestinationPath1) Then<br />
Try<br />
<br />
My.Computer.Network.DownloadFile(DownloadFileWithSourcePath1, DownloadFileWithDestinationPath1)<br />
<br />
Catch ex As Exception<br />
End Try<br />
End If<br />
<br />
End Sub<br />
<br />
<br />
End Class<br />
<br />
DownloadFileInfo procedure is called near about 175 times so total 175 thread is created and in Destination folder i can see the icon of all download files(during downloading).
but after some time (near about 2 minute), these 175 icon is decreased and only few icon are appearead (near about 40). I think all thread is died after 2 minute so file attached to these thread is also deleted (note that files is not completely download)
any body have idea where i am wrong ?
any help will be greatly appreciated.
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
Probably because your downloading 175 files all at once. File download operations are probably timing out because of bunch of threads are all waiting on one to use the network pipe. What you're doing is not efficient at all because the network pipe is not really multithread capable. Only one thread can access the network pipe at a time.
Limit your downloads to only a few threads at a time and it should work. Multithreading does NOT make your application faster, nor does it reduce the amount of time it takes to download a group of files. All it does it make your application responsive during a long running operation.
|
|
|
|
|
hello sir,
thanks for your reply.
What you're doing is not efficient at all because the network pipe is not really multithread capable. Only one thread can access the network pipe at a time
Network pipe is not multi threaded capable. Here i want to know one more thing that what is the downloading criteria when i download files on multiple thread. it downloads all files on all thread partially or it first download one file of thread completely and after that it pick other thread file.
size of all files(175) is near about 6 MB. whether it is possible that i successfully download these files using multiple threads. if yes then Please guide me or provide some link or code snippet
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
My Company
|
|
|
|
|
I thought Dave explained it well enough .. but here goes my shot:
The major choke point in this scenario is the network connection.
High level, ignoring all the details and reality overview:
At heart your network connection is a serial line, pushing one byte at a time to and from your machine.
Those bytes are amalgamated into multiple byte sequences called packets. When a packet arrives at your machine it will be addressed to a logical port number (1-65535). Each of your threads having opened a connection to a remote peer will have a logical port number for that socket connection.
Thus you have 175 open connections, each uniquely addressed, each eagerly awaiting packets from the network connection.
However the first thing I said was that the network connection was serial in nature. Only ONE packet at a time can get through. So for any given moment only ONE thread can receive data. Given that the latency for the network is vastly greater (i.e. slower) then for the core(s) your threads are running on, the OS is happily context switching your threads in and out to do absolutly nothing for most of their lives.
Eventually the network connection (not the threads) time out due to inactivity or failure to tranfer the data - this behaviour is desired and shouldn't be altered unless absolutly necessary.
The best analogy I can think of is a cookie jar with a small opening. One person can reach in and take cookie after cookie. A dozen people reaching in will get their hands stuck and get few if any cookies.
To make a long story short, the optimal number of threads for this operation is : 1
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
Damn, you beat me to it! I was on the road between sites.
Great explanation! That's pretty much what I was going to tell him.
|
|
|
|
|
There seems to be a lot of confusion over threading out there. I think the most egrarious use of threads I ever reached was 5, which I scaled back to 3 in a back-end service (controller, listener, worker). 175 is pretty impressive
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
Hi
I created this code for wildcard search and it doesn't work. I have VB5 express.
code:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim SearchName, mySQL As String
SearchName = "'%" & PriimekToolStripTextBox.Text & "%'"
mySQL = "SELECT SLUŽBA.Priimek"
mySQL = mySQL + " FROM SLUŽBA"
mySQL = mySQL + " WHERE (((SLUŽBA.PRIIMEK) Like " & SearchName & "));"
rsMyRS = dbMyDB.OpenRecordset(mySQL)
End Sub
VB alerts:
- rsMyRS not declared
- dbMyDB not declared
how do I do that. I have DataSet and TableAdapter set to this form2.
Bye
modified on Friday, December 21, 2007 6:58:20 AM
|
|
|
|
|
BOREC wrote: I have VB5 express.
No, you have VB.NET 2005 Express. There was an old version of VB5 that didn't have an Express edition. Mentioning that version will confuse people, and greatly affect the answer you get.
BOREC wrote: I created this code for wildcard search and it doesn't work.
What database are you using? Wildcards are NOT the same between different databases.
BOREC wrote: VB alerts:
- rsMyRS not declared
- dbMyDB not declared
You haven't declared these variables and told the compiler what types they are supposed to be. This is a very basic mistake. I highly suggest picking up a beginners book on VB.NET and working through it.
|
|
|
|
|
I have MS VB 2005 express edition like it says with microsoft.NET Framework 2.0. I know what declaring variables means I wanted to ask you what variables should I declare there.
Obviusly you don't know much abaut programing yourself cause you call quite a lot of people on this forum newbies and insult them. I think you don't get out too much and spend too much time with your computer. Well anyway I don't want to go down on your level, but you had it comming.
Certainly I see the point why programers create such tools with no good support, so people buy your books and pay for other help too. And the great thing would be, that when someone learns VB 2005 the next year will be released VB6 and you can start practicaly all over again ( buy new books, learning classes, so on,... ) Well enough of that thanks for your help. Nothing good is for free ain't it.
|
|
|
|
|
BOREC wrote: I have MS VB 2005 express edition like it says with microsoft.NET Framework 2.0.
The only way I knew you were using VB.NET instead of the old VB5 is the code snippet you posted. Someone else may not see that misdirection.
BOREC wrote: I know what declaring variables means I wanted to ask you what variables should I declare there.
It's impossible to tell what types to declare those variables as from the tiny code snippet that you posted. If you're writing this code, you should have known what these are supposed to be. It's quite obvious that your typing in code that you found laying around somewhere, but you have no idea how it works.
OpenRecordSet is not a method on any .NET BCL class. So this method has to be defined in either some other class in your project or in a 3rd party library somewhere.
BOREC wrote: Obviusly you don't know much abaut programing yourself cause you call quite a lot of people on this forum newbies and insult them.
Excuse me, but how did I insult you?? From the questions in your original post, it's quite obvious you're a beginner at this.
And, no, I haven't written any books, nor did I recommend any. I have no vested interest in any books past, present, or future. All I did was suggest picking one up so you can learn the basics. The questions you asked are a direct result of not knowing what a Type is, how define your own custom classes, OOP concepts, and how to use an external code library.
These are basic concepts that apply equally to VB5, VB6, VB.NET 2002, 2003, 2005, 2008, and all future versions of VB.NET...
|
|
|
|
|
Steady as a rock, you've got my 5.
|
|
|
|
|
Thanks!
I've got a munchkin on the way, so I have to practice keeping a level head around him.
|
|
|
|
|
You're in luck then, this site provides ample opportunity to practice...
|
|
|
|
|
|
Hi ,
I liked the visualbasic powerpacks but i amnot able to use the shape controls like the other controls (in system.windows.forms ), when i am creating an instance of shape control and adding it to the picture box it is raising exception
"Value of type'Microsoft.VisualBasic.PowerPacks.RectangleShape' cannot be converted to 'System.Windows.Forms.Control'.
I want to use those controls like label,Tb,Checkbox and i want to add to the picturebox control .Is there any other way to create line,Rectangle ,oval and add to the picturebox .I reallly want these things in my application
DVS
|
|
|
|
|
Don't use a PictureBox control, try using a Panel instead. The PictureBox is one of the most abused and overused controls in the ToolBox by newbie's, right along side the TabControl.
I dont' have the powerpack here, but I've got it at work. I'll try it when I get there.
|
|
|
|
|
Thanks For Reply ,
But presently , i am creating controls like TB,RB,PBox,Grid labels ,etc on the picturebox at runtime .Like that i wanted to create the oval ,rectangle,line shapes . This way i have to create on picturebox as a base .Upto now everything is fine .Now i struck with these shapes .If they accept like other controls there is no problem .
In some way i have to create .
Vstudio team creates any type of control on the form .Like that i want to create all the type of controls on picturebox .
I have to find some solution ??
Pls help
Dvs
|
|
|
|
|
dvsriram wrote: But presently , i am creating controls like TB,RB,PBox,Grid labels ,etc on the picturebox at runtime
So what?? A PictureBox is used for displaying an image. You're not showing an Image, are you?
A Panel control is a container specifically designed to hold other controls.
OK. I looked into how the PowerPack shapes work. When you drop a shape on a form, there is a container control that is automatically created, called, oddly enough, ShapeContainer and is named, by default, ShapeContainer1. You have to add your shape controls to this container, or if you don't drop an initial shape on the form, you have to create the ShapeContainer instance yourself.
Example:
Imports Microsoft.VisualBasic.PowerPacks
.
.
.
Friend WithEvents myContainer As ShapeContainer
Private Sub Form1_Load(blah, blah) Handles Form1.Load
myContainer = New ShapeContainer()
With myContainer
.Location = New Point(0, 0)
.Dock = DockStyle.Fill
End With
Me.Controls.Add(myContainer)
Dim newShape As New LineShape(130, 5, 5, 150)
newShape.Parnet = myContainer
End Sub
...
|
|
|
|
|
Thanks , It got to work on panel ,picturebox ,But presently i changed from picturebox to panel
Dim ctr As ShapeContainer = New ShapeContainer()
Dim sh As RectangleShape = New RectangleShape(ctr)
sh.BorderColor = Color.Blue
sh.BorderStyle = Drawing2D.DashStyle.Solid
sh.BorderWidth = 3
sh.Left = ihorizontal
sh.Top = ivertical
sh.Width = 40
sh.Height = 50
cs.WireControl(ctr)
panelActiveCanvas.Controls.Add(ctr)
This cs class is used for control resizing ,moving
For this i used this one
http://www.codeproject.com/KB/miscctrl/CSPickBoxSample1.aspx?df=100&forumid=23756&exp=0&select=1266133&tid=1266133[^]
it is taking all controls & moving and resizing except the shape controls ,
While clicking on the rectangle it is selecting the panel but not getting the pickbox to resize ,moving
How can i get exactly like Visual studio powerpacks control drag & drop on form ?????
Dvs
|
|
|
|
|
If method to be invoked in thread is "callThread()"(without parameters)
we are following
Thread testThread=new Thread(Addressof callThread)
testThread.start()
But I want to the method which has some parameters
ex: callThread(ByVal s as string,ByVal i as integer)
{
}
how should i call this method using threading
Please advice me
Thanks in advance
Praveen Kumar Palla
|
|
|
|
|
praveenkumar palla wrote: how should i call this method using threading
That depends on which version of VB.NET you're using. 2002, 2003, 2005, or 2008??
|
|
|
|
|
thanks for the response
using
VB.Net 2005
|
|
|
|
|
i am creating a backup programme. My Question is that when i copy a folder to another location and if the folder is already exist then it should overwrites only those folders whose modifed date is older than today. so please tell me how can do this. Anyone have codes........
Thank you
Dharmendra
|
|
|
|
|
The easiest solution is to compare dates.
|
|
|
|
|