|
i have 2 textboxes and each of the textbox is running on different thread. If i wan to display the value which is on the txtbox1 to txtbox2 i have a error can cross-thread operation not valid. What should i do to solve tis problem?
|
|
|
|
|
try this
use files to trasfer data between your textboxes.
write content of textbox1 text to a temporary file, read it from second thread and put it in the second textbox2.
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
Maybe using a delegate ...
|
|
|
|
|
|
Dave Kreskowiak wrote:
Yep. Almost made me gag on my coffee reading the suggestion of using files
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
|
Dave Kreskowiak wrote: I spewed Coke out my nose
Thanks for the mental picture
Dave Kreskowiak wrote: onto my (work) laptop. Please, don't tell anyone!
Oooooooooooooooooh, busted Ummm, I didn't see or read anything, boss. I swear
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Fatal Error wrote: use files to trasfer data between your textboxes.
write content of textbox1 text to a temporary file, read it from second thread and put it in the second textbox2.
Well, while that is possible to do so, it is not very efficient.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
You cannot access controls from threads other than the one that created the control. It's also a really bad idea to create controls on anything other than the UI thread (the one the application started on).
You might want to read this[^] and this[^].
|
|
|
|
|
I am opening an existing Excl sheet in a AxWebBrowser (that's the easiest way i got) on a window form created by VB.net 2005.
My issue is that i am not able to : close the file so when i try to open another file or over write the same file (on HDD) i am not able to do it.
Also i find the excel exe (in the task manager) running in the back which is not freeing the excel.
What can be done to solve these issues?
Regards
Nishkarsh
|
|
|
|
|
after use of excel sheet close the sheet then only open another sheet...
May be it will work...
Ananda
|
|
|
|
|
that is exactly what i do not know how to do? Any idea apart from killing excel.
|
|
|
|
|
try this
just kill the excel process from the task manager, from your application.
use this below code.
Public Sub Kill_Application(ByVal ApplicationName As String)
Try
Try
Dim processList1() As Process
processList1 = Process.GetProcessesByName(ApplicationName)
For Each proc As Process In processList1
proc.Kill()
Next
Catch
End Try
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
Thanks a lot, it works
the only issue with this is it will close all the instances of excel, which means if the user is working on any Excel sheet apart from our application it will also get closed. Is there a way out?
Regards
Nishkarsh
|
|
|
|
|
|
Let this be the webmethod:
<br />
<webmethod()> _<br />
Public Function HelloWorld() As String<br />
Return "Hello World"<br />
End Function<br />
I have a test harness which is a windows form and I would like to send a request and receive a repsonse asynchronoulsy. Please help me with the code asap.
Thank you
|
|
|
|
|
dreddy7 wrote: the code asap
Not the way it works around here.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Sorry I did not understand!
|
|
|
|
|
People don't just hand over code when someone needs it urgently or right away.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I am not asking people to do it right away keeping their work aside. People who cant help need not bother at all and better be off. I am asking only those who have already worked on it and who can guide me in the right direction.
|
|
|
|
|
dreddy7 wrote: I am asking only those who have already worked on it and who can guide me in the right direction.
I did some web services stuff the other day, investigating how to consume web services through a silverlight app.
Have you made a reference to the web service in your project?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I have added it as the web reference to my windows app project and created an instance of it to call the web methods.
|
|
|
|
|
Ok. What code have you done in your windows app to create the instance and method call? Sounds like you are so far on the right track.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
This may be silly, but do you have the web service running?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Yeah the web service is running...I am actually new to web services. So, is there any way to confirm if it is actually running or not. And the code that I have on my Windows app is a simple one for now.
On a button click event , it just says:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Cool is the name of my webservice
Dim objService as New Cool.Service
TextBox1.Text = objService.HelloWorld()
end sub
And the web method in the Cool Service is:
<webmethod()> _
Public Function HelloWorld() As String
Return "Hello World"
End Function
Now what is an asynchronous web request-response? I have the following method which does a httpwebrequest-httpwebresponse:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim myHttpWebRequest As HttpWebRequest
Dim myHttpWebResponse As HttpWebResponse
Dim receiveStream As Stream
Dim encode As Encoding
Dim sr As IO.StreamReader
Dim strUrl As String = "http://localhost:5404/CoolService/Service.asmx"
Try
myHttpWebRequest = CType(WebRequest.Create(strUrl), HttpWebRequest)
myHttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
receiveStream = myHttpWebResponse.GetResponseStream()
encode = System.Text.Encoding.GetEncoding("utf-8")
sr = New StreamReader(receiveStream, encode)
Do Until sr.Peek = -1
TextBox2.Text += sr.ReadLine
Loop
Catch ex As System.Net.WebException
MsgBox(ex.Message)
Finally
sr.Close()
myHttpWebResponse.Close()
End Try
End Sub
Is this asynchronous?
|
|
|
|