|
Nope. Far from it. Read[^]
|
|
|
|
|
In my application I have a process that can take quite a bit of time to run (so I have it in it's own thread so I can display progress to the user). In the event that a 2nd process starts I need to pause the thread, then restart it once the 2nd process is complete. When I use Thread.Resume to restatt it it displays a warning
Public Sub Resume()' is obsolete: 'Thread.Resume has been deprecated.
Please use other classes in System.Threading, such as Monitor, Mutex, Event, and Semaphore, to synchronize Threads or protect resources.
What are the acceptable replacements for .Resume as I have Google'd it and cant find the answer
"It's only that urgent if you have to pee."
Dave Kreskowiak
|
|
|
|
|
Psycho-*Coder*-Extreme wrote: I need to pause the thread, then restart it once the 2nd process is complete
How did you "pause" this thread?? I hope you didn't call Abort() on it. Once a thread is stopped, that's it, you can't restart it. You have to destroy it and create another one.
Your thread should be checking for a flag set by your main thread to tell it to "pause". Once the 2nd process completes, you can reset this flag telling your first thread to resume.
|
|
|
|
|
For pausing it I use
'Put the thread to sleep for as long as I need it
Thread.Sleep(System.Threading.Timeout.Infinite)
'Set the flag
bIsPaused = True
Then to resume it I use
'Check the status of the thread
If thrdAgentStatus.ThreadState And ThreadState.Unstarted <> 0 And Not bIsPaused Then
thrdAgentStatus.Start()
Else
thrdAgentStatus.Resume()
End If
My problem is that the .Resume gives a warning that it is depreciated and I was trying to find an alternative so I can get rid of this warning.
"Okay, I give up: which is NOT a real programming language????"
Michael Bergman
|
|
|
|
|
Psycho-*Coder*-Extreme wrote: 'Put the thread to sleep for as long as I need itThread.Sleep(System.Threading.Timeout.Infinite)'Set the flagbIsPaused = True
OK. That's not going to work. The flag is never set because the thread sleeps, or Blocks, immediately. Start and Resume will not "wake up" a blocked thread. You have to call the Thread object's Interrupt method to unblock a blocked thread.
Dim oThread As System.Threading.Thread
oThread = New Thread(AddressOf Me.Fill)
oThread.Start()
oThread.Sleep(System.Threading.Timeout.Infinite)
Dim retValue As MsgBoxResult = MsgBox("Wake Thread?")
If retValue = MsgBoxResult.Yes Then
oThread.Interrupt()
End If
|
|
|
|
|
Hi, I'll try to make this as brief as possible.
I have an app that references SAE standard DLLs (RP1210a in case anyone cares) to communicate with external devices. Many different vendors supply these DLLs with their hardware. My app needs to be able to reference any of these depending on which one the end user is using.
My problem is I cannot declare Functions to each DLL because I get the "Multiple definitions with identical signatures" error.
example,
Declare Function RP1210_ClientConnect Lib "DG121032" (ByVal hwndClient As Short, ByVal nDevice As Short, ByVal fpchProtocol As String, ByVal lTxBufferSize As Integer, ByVal lRcvBufferSize As Integer, ByVal nIsAppPacketizingIncomingMsgs As Short) As Short
and
Declare Function RP1210_ClientConnect Lib "NXULNK32" (ByVal hwndClient As Short, ByVal nDevice As Short, ByVal fpchProtocol As String, ByVal lTxBufferSize As Integer, ByVal lRcvBufferSize As Integer, ByVal nIsAppPacketizingIncomingMsgs As Short) As Short
Hopefully this makes sense, and any help would be GREATLY appreciated.
|
|
|
|
|
You can't name a function the same as another unless you are doing an override or overload of the function. If you want to make a function that will in turn call the DLL function, name it something different.
|
|
|
|
|
A co-worker suggested I need to use System.Reflection.Assembly to solve this problem. Any experience with this?
|
|
|
|
|
No, I don't recall ever using the System.Reflection.Assembly namespace. And I think I misunderstood your first question. I was thinking that the DLLs were .Net and you were just trying to use them...but now I understand that you were trying to define non-.Net DLL methods them so that you could call them. This is something that I've never had to do. Sorry I couldn't help you.
|
|
|
|
|
Hey, no problem. I really appreciate the help anyway!
You are correct, I am trying to define methods in non .net DLLs. If I find a solution I will post back in case anyone else runs into this.
Otherwise, anyone else have a solution?
|
|
|
|
|
I am working on a program that communicates with a device using a Rs232 serial cable. I have to send data packets to it. I have never dealt with data packets. I assume they are not strings? Can you suggest some articles I can read up on. OR give me some code that I can reference.
EX: I need to send this. How would I send this?
<0x02>PSWD<0x01>Passwort<0x03><0x1F><0x7F>
|
|
|
|
|
A packet is just nomenclature for a defined block of data, usually with a header - payload - trailer structure. The exact layout is protocol specific, so in this case it sounds like you have carte blanche.
Typically however the header will be structured so that it is easily identifiable as such.
If the packets are not fixed in length then it will typically contain the size of the payload (since both header and trailer are usually fixed length this is also sufficient to figure out the size of the packet).
Also the header will typically contain the destination and source addresses. Not an issue with RS232!
The payload is whatever needs to be communicated.
The trailer usually contains a checksum of the packet for error correction.
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
You're going to have to build a string to send. There's a bunch of ways to do it, but this works in a short example:
Dim passwordCommand As String = Chr(&H2) & "PSWD" & Chr(&H1) & "{0}" & Chr(&H3) & Chr(&H1F) & Chr(&H7F)
Dim setPasswordCommand As String = String.Format(passwordCommand, "MyPassword")
You then send the string contained in setPasswordCommand to the COM port you opened using the SerialPort class (.NET Framework 2.0 and above only).
|
|
|
|
|
Here is my code.
When I send a string SERIELL. The device is suppose to send back a confirmation string 'OK'. When I do a MessageBox.Show(serialPort.ReadChar) I get two message boxes one with 79 one with 75. These are UNICODE for 'O' and 'K'. GOOD
But when I send this for a password I am suppose to get ACK or 0x06 back and I only get a 21 back. Do I need to send in UNICODE? Binary? Hex? What are your thoughts? The original code was ANSI-C or C#.
Dim passwordCommand As String = Chr(&H2) & Chr(&H50) & Chr(&H53) & Chr(&H57) & Chr(&H44) & Chr(&H1) & Chr(&H50) & Chr(&H61) & Chr(&H73) & Chr(&H73) & Chr(&H77) & Chr(&H6F) & Chr(&H72) & Chr(&H74) & Chr(&H3) & Chr(&H1F) & Chr(&HF7)
|
|
|
|
|
No idea. I don't have the device to toy with, so it's impossible for me to test. It could be that's an error return. I have no way of knowing since I don't have the documentation and I don't have the device. For specific programming support on the device, the manufacturer of it is your best source of information.
|
|
|
|
|
I'm using VS2005, and have a problem using the datagrid. I'm building a form to create a member's details, including a member's list of jewels. I've combined all one to one member's details into one table, the member table, except the member_jewel table, because a member can have zero or more jewels. The jewel part is where I stuck. The member_jewel has 3 attribues only: memberID, jewelName and dateAward.
I want to use Datagrid or others to have a list of jewels a member has without showing(and inputting) the memberID on the datagrid. I mean I want two columns only on the datagrid: jewelName and dateAward; the memberID on each row of the datagrid could be hidden and be saved automatically. Anyone please help me. Thank You.
Ryan
|
|
|
|
|
Is there code to open a jpg if I were using the vb editor in MS access? I need to click a button, then open the JPG. I have tried looking for controls but all are shareware which unfortunately is out of the question for my project. Does anyone know how to do this? I just need the picture to display (even if it is in the 'crappy' Windows Picture and Fax Viewer or whatever its called) Thanks a bunch.
|
|
|
|
|
Just pull the picture from the database and dump it into a picture box control...
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Sorry, I wasn't clear enough...the picture is just saved on the local machine, not in my database...I just need to open it using the filepath as a parameter. I'm going to use a button and its Click() event to automatically browse to this path and open it.
|
|
|
|
|
A simple example:
Private Sub Command1_Click()
Me.CommonDialog1.ShowOpen
If Me.CommonDialog1.FileName <> "" Then
Me.Picture1.Picture = LoadPicture(CommonDialog1.FileName)
End If
End Sub
However you get the path\filename of the jpg (or bitmap or GIF), just load it into a picture box with the LoadPicture function.
|
|
|
|
|
How do I use a PictureBox?
Right now I have
Dim picbox As PictureBox
'tried this and didn't work'
picbox = LoadPicture("C:\file.jpg")
'tried this and got "type mismatch"'
Set picbox = LoadPicture("C:\file.jpg")
|
|
|
|
|
I'm not very good at programing, and when i tries to save the bitmap to a file i get the "A generic error occurred in GDI+." what am i doing wrong? I wrote a smal app to demonstrate what my problem is. In the real app it modifies some exif data and are then supposed to save the file.
Public Class frmSaveFile
Private _bitmap As Bitmap
Private _filename As String = "d:\husvagn.jpg"
Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpen.Click
_bitmap = New Bitmap(_filename)
btnOpen.Enabled = False
btnClose.Enabled = True
End Sub
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
_bitmap.Save(_filename)
btnClose.Enabled = False
btnOpen.Enabled = True
End Sub
End Class
|
|
|
|
|
It errors out because the original file is locked by the Bitmap object that you loaded the image into. You can get around it by loading the image using a FileStream instead. See this[^] MS KB article for a sample.
|
|
|
|
|
You saved my day, Thanks.. I learn something new everyday!
|
|
|
|
|
Using VB6, I created an XML file, but now I need to save it to a network location that has security on it. Is there a way to save it the the network location, specifying what the username and password?
Thanks.
|
|
|
|