invoker = New GeneralDelegate(AddressOf RefreshUserList) UsersTreeView.Invoke(invoker)
that's a code from the PopulateUsers()
sub... unless i'm missing something this kind of action will create threads until something bad will happen , am i missing something :confused: ? i'll assume that either i am, or you have modified the code to invoke the RefreshUserList sub every 5. now i think that it might be best not the destroy the previously created thread, but to monitor it's existence, possible by using a global or shared boolean member probably named 'blRefreshingUserList', each time you enter your timer event, before you create a new thread check and see whether the previous one has finished. Although i don't see a scenario in which you won't finish refreshing in 5 secs. in 5 secs you can add A LOT or info, i think that something else is wrong, if you wold like to send me the code and tell me what you want it to do, i'll check it and see why it is not working. if not, you may also present more info so i can help you better, your choice (i won't steal your code anyway though) Fade (Amit BS)
Fade Amit BS
Posts
-
Thread Problem -
Thread Problemyou are invoking 'RefreshUserList' from within the 'PopulateUsers' method :rolleyes: ? that can't be good... AND you should invoke ALL the GUI related methods by delegates as you did in usersTreeView.invoke(Invoker) otherwise strange things happen. Fade (Amit BS)
-
system.io.streamreader.readlinei would do it differently, instead of peeking into the file (which is generally not a good thing to do due to various reasons) use this statement instead
while MyStramReader.BaseStream.Position < MyStramReader.BaseStream.Length ...
should also work faster :) (i think...) Fade (Amit BS) -
MDI Forms and Child Formsif all you need is to write to a file, simply use the FileStream object in the frameworks (if it is then the title of your message is VERY misleading, if not, then my reply is useless :) ) the basics are to create a FileStream object reference
Dim MyFileStream as System.IO.FileStream
and then you need to create the file stream, by opening the file if it is a new file (there isn't a file with the same name at the same directory) you should create the file like so:MyFileStream = IO.File.Open(MyFilePath, IO.FileMode.CreateNew)
if the file already exists, you would probably want to erase the data and rewrite it do:FileStream = SystemIO.File.Open(MyFilePath, IO.FileMode.Truncate)
to check whether the file exists use:If System.IO.File.Exists(MyFilePath) Then ...
if you want to be really smart about it, you can scan the file to see what segements of have been chaged and only write those parts (mostly usefull in large files) Fade (Amit BS) -
TabControli'm not sure that i understand your question, and i got a pretty 'Go-Around' solution for the question i *think* you have asked. you can load and display any image on any object, using BitBlt. read this article i wrote http://www.codeproject.com/vb/net/Bitblt_wrapper_class.asp[^] you can load a bitmap and use this class to show it over the tabcontrol. or you can think about it and probably find a better way to do it :) Fade (Amit BS)
-
How to show a form after closing it ..The reason the child form is destroyed is becuase you loss all references to it. if your working in vb.net you need to create a variable in a different class, holding a reference to your created form, or the reference can be 'Shared' (which i don't reccommend) if you are working in vb6, you can try do the same as for the .net (but i'm not sure if it would work) or try to create the form in a different parent form. you can also monitor the form's 'Closing' event(.net) or 'QueryUnload' event(vb6) and then you can cancel the termination of the form and just hide it. in both cases you need to set the 'Cancel' parameter to 'True'. Fade (Amit BS)
-
Messenger users online/offline?am telling you this for a fact, the messager has an open connection with the host, you can see it for yourself by using the "netstat -nao" command in the command prompt (run "cmd") this will show you all active connections on your computer, including the process ID associated with each connection. you can see which process id the messager uses using the Task Manager. Select the 'Processes' tab, and then 'View' -> 'Select Columns' (this option will only show when you're in the 'Processes' tab). then you'll see that the messanger process has an established connection. now, how is it done? as one server might not be able to support so many simultanious connections? If you will take a minute to experiment, you'll see that each time you log-on, the messanger logs on to a different IP, that's the load-balancing machanism, microsoft has many Messanger servers, each serving who knows how many users, and on the servers level, they are responsible for updating eachother. It sometimes takes a minute until the messanger detects a connection loss because connection loss on tcp connection is not always detectable, so it is only detected after some timeout occurs in your client (there is probably a reflecting timeout at the server side too) by the way, they probably went for the open connection architecture due to the fact that many users cannot accept incoming transmissions (everyone behind a router, ICS server, proxy, firewall etc.), the only way they can be sure they can send you data (like an incoming message) is an open connection you have initiated that's about it :) Fade (Amit BS)
-
Exporting VB.Net DLLs to VB6i'm sorry but if it was that simple i wouldn't have posted this question. that problem is exporting the created control to vb6 thanks for the effort though :) Fade (Amit BS)
-
Open a form on socket receiveThe windows forms will behave abnormally when you try to access them forom a different thread then they are, and as you are probably getting the communication message on another thread you cannot directly control the forms BUT! the .net developers have been kind enough to porvide us with the 'Invoke' method, which is a member of each and every control (forms, buttons etc.) this allows you to tell the control (form for this matter) to do something in it's own thread what you need to do is to create a method (sub) that creates the new form and assigns it to a variable, that method should be located in your startup form, or any other form you want to use.
private AdminFormMember as AdminForm Private Sub CreateNewForm() AdminFormMember= New SocketControlForm() AdminFormMember.Show() End Function
and Create a delegate to it like soprivate delegate sub CreateNewFormDlg()
and call it from your code when you want to create to new form using the 'Invoke' method, like so:If (OpenAdminForm = True) then ' Creating a delegate instance dim CreationDelegate as new CreateNewFormDlg() ' invoking it from the main form's thread ! MainForm.Invoke(CreationDelegate) end if
That's it, not too complicated and it works, trust me ;) Fade (Amit BS) -
TcpClient create a memory leak ?!?i wouldn't jump the gun and say there is a memory leak a good thing to know about the grabade collector in .net is that it collects garbage when it wants to :) an easy way to see this for yourself is to sequencially create and destroy let's say 100,000 objects. open the task manager to watch the memory status as the code runs for whatever time it takes him (i would even put it in a never ending loop just for the sake of the example) the loop should be something like { CreateObject(); DestroyObject(); } you will notice how the memory starts to fill up, and then just when you think the system is about to die, you'll see how in a second it all comes back to normal - that's the garbage collector waking up and doing it's job :) Let me know if it is a leak or just the garbage collector so i'll know whether to use the tcpClient. Fade (Amit BS)
-
Distributing Dlls written in .Net to VB6i'm sorry, but the article you mentioned only works for c#, i need it to work with vb.net, i've tried MANY methods to attack this problem and i keep getting dead ends. i need some kind of an example vb project that can compile to an OCX, or a referencable DLL from VB6 (i can't get the vb.net project to strong name - there is no option in the 'Properties'->'Build' to set a key...) please let me know if there is some way to do this, it will save me weeks of work i need a vb.net project that compiles to a working something in vb6 thanks for the effort Fade (Amit BS)
-
ListView move Up / Down using Index ??It doesn't work becuase.... oh, i'll just show you The list: Item1="1" Item2="2" Item3="3" OK? now lets say you want to move the item at index 2 one step down, your code does two things, add a new item, and removes the old one, right? lest do these two steps- Step 1 - add new item Item1="1" Item2="2" Item3="2" Item4="3" Now if we remove item at index 2+1 (item3 now) what do you think will happen? what you need to do is switchi between the item(index) and item (index+1) the same thing will work with moving an item upwards - switch item(index) with item(index-1) it will be a lot faster then using the insert/b> method, trust me :) Fade (Amit BS)
-
Distributing Dlls written in .Net to VB6First, i know this isn't the best place to post this article but i felt this has something to do with the frameworks... I have a really big application running on vb6, it will take months to port it to .net in the meanwhile i need to use some GDI+ capabilities (and some threading). I wrote some DLLs that will do the job for the big applications, but i don't know how to export them to VB6, When i'm trying to add the reference to the DLL, it gives me an error message that it cannot use that kind of DLL. I thought of using OCXs instead, but i don't seem to find a way to create an OCX in VB.Net (i know i can do in c++/# but i have tons of code already written in VB.net and i'm on a tight schedule) Can anyone help me out? Fade (Amit BS) Fade (Amit BS)
-
Halt Sequencedepending on what you are trying to do, there are two main options: 1. Causing the Code to completly halt can be done by using the Sleep method (i saw you got a got overview of it) or by looping like you did BUT - add a DoEvents() call inside the loop, this will allow the window to redraw this approach of halting is not very safe to begin with, especially in VB6 that runs EVERYTHING on a single thread. you might want to try these two approachs: 2. Timer based halt. Create a timer object, and set it to start timing you in the 'Wait' method handle the timer's "Timer" event, in the hanlding sub a. disable the timer b. call a method to continue the operation there are additional ways to achieve this, but i think this will get you going Fade (Amit BS)
-
Help making a listbox appear when I write somethingFirst of all, there are two different questions here 1. How to cause the Listbox to become visible when i want to? very self explenatory, there are two options: a. create the list box in design-time, with the 'Visible' property set to 'False' then, when you want it to become visible change the property b. create the list box dynamically in run-time which i will not explaine here there are a lot of articles describing this 2. How to "sense" that the somthing specific is being written ? Well.... basically there is an event fired when a text in a textbox is changed (there are also a lot of examples on handling events) handle this event and check what has changed, you can keep a copy of the content in the textbox, and when it changes compare both copies, you can scan for the last changed character backwards to see what is written, there are many possibilities, pick one. Hope this helps, you are being very vague next time try explaining what you are trying to do, like "i'm trying the sense when someone is typing a url so i can highlight it". ok ? ;) Fade (Amit BS)
-
Peep2peer, choose ports for TCPFirst of all, Don't Panic :) Basicly what you need to do is pretty simple. First, decide on one port number (for instance 7070 you mentioned), now both peers listen on that port, and both peers know that they are both listening on that port. When Peer A wants to send a file to Peer B, it creates a new socket (do not bind that socket to ANY port) and connects it to Peer B (by the known port). Now- Peer B will receive a 'Connection Request', and creates a new socket to accept the new connection. At this point, Peer A can send asorted information about the file it want to send like size, file name hash etc. and then begin to send the file. Because this is all happening on different sockets than the listening ones, both peers can initiate any additional number of connection as you wish (well not any number of connections but a reasonable one :) ) That's it, note that Peer A can also connect and Request a file from Peer B, the possibilities are endless. I can send you an example project i wrote with all this connection creation working, i will post it with an article, but it will take some time as i'm on a tight schedule now and can't write the article now. Let me know if you want the example. Fade (Amit BS)
-
Exporting VB.Net DLLs to VB6I have a really big application running on vb6, it will take months to port it to .net in the meanwhile i need to use some GDI+ capabilities (and some threading). I wrote some DLLs that will do the job for the big applications, but i don't know how to export them to VB6, When i'm trying to add the reference to the DLL, it gives me an error message that it cannot use that kind of DLL. I thought of using OCXs instead, but i don't seem to find a way to create an OCX in VB.Net (i know i can do in c++/# but i have tons of code already written in VB.net and i'm on a tight schedule) Can anyone help me out? Fade (Amit BS)
-
BitBlt LoadImage:(( Can someone PLEASE tell me why this won't work? :((
**_******** Declarations ********_** Private Declare Auto Function BitBlt Lib "GDI32.DLL" ( byVal hdcDest As IntPtr, ByVal nXDest As Integer, _ ByVal nYDest As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hdcSrc As Long, ByVal nXSrc As Integer, ByVal nYSrc As Integer, ByVal dwRop As Int32) As Boolean Private Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As Long, ByVal lpsz As String, _ ByVal dwImageType As Long, ByVal dwDesiredWidth As Long, ByVal dwDesiredHeight As Long, ByVal dwFlags As Long) As Long Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long **_******** Consts ********_** Private Const LR_LOADFROMFILE = &H10 Private Const IMAGE_BITMAP = 0 Private SRCCOPY as Integer = &HCC0020 **_******** Sub that won't work ********_**
Private Sub ShowPicture(ByVal File As String) Dim MemBmpHandle As Long Dim MemHdc As Long Dim Result As Long ' MemBmpHandle = LoadImage(0, File, IMAGE_BITMAP, 776, 84, LR_LOADFROMFILE) MemHdc = CreateCompatibleDC(0) Result = SelectObject(MemHdc, MemBmpHandle) ' Dim Grp As Graphics = PictureBox1.CreateGraphics ' Creating graphics object to BitBlt on Dim TargetDC As IntPtr = Grp.GetHdc() 'Creating target HDC ' BitBlt(TargetDC, 0, 0, 776, 84, MemHdc, 0, 0, SRCCOPY) ' Blitting' Grp.ReleaseHdc(TargetDC) Grp.Dispose() DeleteDC(MemHdc) DeleteObject(MemBmpHandle) End Sub
Fade (Amit BS)
-
Project sometimes won't launchI'm expiriencing a prolem with Studio.Net 2002, sometimes when i 'Start' a project it will compile, the IDE will adapt to running the application (tool bars, windows etc.) but the project won't launch. what i'm doing now is pressing 'Stop' and then 'Start' again and it will work, it happenes about once in every 5 attemps. Any ideas? Fade (Amit BS)
-
Projects and solutionsI got this solved, for anyone who wounders this is the deal: you add the projects to the solution (right-click the solution and then 'add'->'Existing Project' then you have to create a refference. what i didn't notice before that in the 'Add Reference' dialog there is a 'Projects' Tab, you add a refference to the project from there, and the IDE will automatically create a dependancy. Another thing to notice, click on the project reference item, and in the properties window there is a 'Copy Local' property, i think that it's best to set this proerty to 'False'. That worked for me just great, namespace work and everything. Hope this will help someone :) Fade (Amit BS)