|
Hi everybody,
I wonder if anybody can enlight me on this matter! How can I force the premature termination of a background thread? I need to immediately terminate a thread, that could still be running, when I go to a different section of the application.
This is how a create and start the tread:
Public oFireThread As Threading.Thread<br />
<br />
Public Sub Trigger_Thread()<br />
Dim oThreadPoint As New Threading.ThreadStart(AddressOf Load_Data)<br />
<br />
oFireThread = New Threading.Thread(oThreadPoint)<br />
oFireThread.IsBackground = True : oFireThread.Priority = Threading.ThreadPriority.Normal<br />
oFireThread.Start()<br />
End Sub
Please keep in mind that I use the object: oFireThread to start other threads as well!
Thank you so much for you brain-storm!
Alex.
|
|
|
|
|
I think this may help:
oFireThread.Abort()
Regards.
|
|
|
|
|
Hi Nilesh,
Unfortunately I have already tried that approach. It does not do the trick
oFireThread.Abort() : attempts to finalize the thread, after doing I do not know what. I need to force the inmediate termination of this thread by-passing any validations, safeguards, or whatsoever.
Thaks anyway!
Alex.
|
|
|
|
|
That's the only way to do it. Even using this method has it's risks. If your code isn't prepared to Abort, your thread could leave resources and memory orphaned. Stopping a thread immediately will make this situation worse.
|
|
|
|
|
Appreciate your time and help.
Have a good weekend!
|
|
|
|
|
Hi,
I have a asp:GridView on my webpage, and I trying to bind an ArrayList made up of a series of custom structures (myStructure). I want to bind this arraylist to my gridview... so far I have not succedded.
>> ASP GridView
<asp:GridView ID="myGridView" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="startDate" HeaderText="Start Date" />
<asp:BoundField DataField="duration" HeaderText="Start Time" />
</Columns>
</asp:GridView>
>> the structure
Dim myArrayList As ArrayList
Public Structure myStructure
Public startDate As Date
Public duration As String
End Structure
' the arraylist contains serveral myStructures
myGridView.DataSource = myArrayList
myGridView.DataBind()
>>
How would I bind this. I get this error "A field or property with the name startDate was not found on the selected data source."
Help please, I fairly new to all this...
Thanks so much in advance.
-- modified at 22:11 Thursday 22nd November, 2007
|
|
|
|
|
Fergal83 wrote: A field or property with the name startDate was not found on the selected data source."
seems like you disable "Auto-generated column".. Don't add any column at design and don't set the column name in DataField. You should try with auto-generated column.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
"Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
|
|
|
|
|
Thanks for the help, tried it, but it now generates my original error...
"The data source for GridView with id 'myGridView' did not have any properties or attributes from which to generate columns. Ensure that your data source has content."
|
|
|
|
|
The problem caused because of your structure.
Don't use the public variable. Please use "Property" instead of public variable.. then, you will be able to bind to "autogenerated column" or "non-autogenerated column".
Hope it helps..
The following code is tested..
public struct myStructure {<br />
public string duration;<br />
public String Duration<br />
{<br />
get{<br />
return duration;<br />
}<br />
set<br />
{<br />
duration = value;<br />
} <br />
}<br />
}<br />
public partial class _Default : System.Web.UI.Page <br />
{<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
System.Collections.ArrayList myArrayList = new System.Collections.ArrayList ();<br />
myStructure mys1 = new myStructure ();<br />
mys1.duration = "aa";<br />
myArrayList.Add (mys1);<br />
GridView1.DataSource = myArrayList;<br />
GridView1.DataBind ();<br />
}<br />
}<br />
Note: Sorry for C# code. you can easily convert it to vb.net code..
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
"Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
|
|
|
|
|
Worked a Treat!
Thank-you so much for that.
|
|
|
|
|
glad to hear that.. Please vote the message if it's helpful for you.. thanks.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
"Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
|
|
|
|
|
Hi Michael
I have a problem when binding a list of hashtable to grid view.
List<Hashtable> list1 = new List<Hashtable>();
GridView1.DataSource = list1;
GridView1.DataBind();
the output i get is
IsReadOnly IsFixedSize IsSynchronized Count
10
10
where my list1 has two hashtables with each having 10 items each..
Any pointers on this?
|
|
|
|
|
I wrote the code to start a song, and it works. Except I would like it to (laundry list)minimize windows media player once the media player has started playing the song (if possible, not show windows media player at all, have it hidden or something), to exit the media player once the song is done playing, and close windows media player once my program is closed.
I know this is a lot to ask for but it will be much appreciated.
my code for starting the song
Process.Start("H:\the song.mp3")
thanx
|
|
|
|
|
Your 'code' is launching WMP and then losing control over it. Put a windows media player control inside your app and you will have full control over how it looks and what it does.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
That’s what I originally had in mind but I don't know how to so I went with what I know. If you could give me a sample or somethin' to start me off in the right direction that would be most excellent.
TY
|
|
|
|
|
Right click on the toolbox, select 'Choose Items' Find the media player control, add it and drag it onto your form. There's tons of docs online. The ctlControls property contains all the methods to control playback.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
You may try this way if you don't wanna integrate WMP in your application.
http://www.codeproject.com/csharp/wmp_pinvoke.asp
If you wanna integrate WMP in your application, please follow the steps
- You have to add WMP to your toolbox.
Toolbox -> Right-click -> Choose Items - > COMS- > Windows Media Player
- then, place this control on your form..
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
"Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
|
|
|
|
|
Hello every one
I am studing vb.net-2003 and i want to create HTML help in my project so which one is the best and easy tool to do this i have tried MS HTML workshop but to me it's looks very confusing
so is there any simple and free tool available?
waiting for your kind rep.
thanks
|
|
|
|
|
bapu2889 wrote: i have tried MS HTML workshop but to me it's looks very confusing
Every software looks confusing until you get used to it. I have tried using it in my project. MS HTML workshop is pretty nice..
If you wrote the well-comments in your code, you can generate the HTML doc by using NDoc or other doc generator..
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
"Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
|
|
|
|
|
Check out the classic NDOC:
http://ndoc.sourceforge.net/[^]
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson
|
|
|
|
|
Hi,
my application runs in background and has no visible window. But I need the WM_POWERBROADCAST Message. I've tried a dummy window but WndProc() is called only if the window is visible.
How can I receive window messages without a visible window?
|
|
|
|
|
ponchofiesta wrote: I've tried a dummy window but WndProc() is called only if the window is visible.
Not true. Non-visible windows will get their WndProc procedure called too. The message that you're looking for only goes to top-level windows, visible or otherwise, not to child windows.
What's your app's startup object?? Sub Main or an actual form?? If it's a form, did you override the WndProc of the startup form, or some other form in the app?? If Sub Main, what does that code look like?
|
|
|
|
|
hi everyone!
a friend of mine wants to do this szenario:
do several transactions and if it was successful then delete the source and continue. if it was not successful then skip all other things and goto below the operations.
meaning (in pseudo code):
on error goto errorhandling
operation 1
operation 2
operation 3
operation 4
...
operation n
errorhandling:
newthings
this means if an error occures in operation 1 to n the program has to continue with the operations starting at errorhandling:. if it is successful then it does all the operations but continues at errorhandling: as well.
when he tries to compile his code the compiler throws an error message at the position, where "errorhandling" starts in the goto-line.
i am not sure if it is possible to do this. because he wants to do some operations which are finished with a delete operation as operation n. but if one of these operations throw an exception all other would do as well. so there is no reason to try these.
does anyone of you know if this is possible to just skip some lines and to continue at a certain point if an error occures. but if no error occures the programm does line by line.
thanks.
stephan.
|
|
|
|
|
What about if you move the error handling in operation function?
Your_Main_Function()<br />
operation 1<br />
operation 2<br />
operation 3<br />
operation 4<br />
...<br />
operation n<br />
End<br />
<br />
Sub operation 1<br />
on error goto errorhandling<br />
<br />
errorhandling:<br />
newthings<br />
End sub
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
"Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
|
|
|
|
|
Michael Sync wrote: What about if you move the error handling in operation function?
Your_Main_Function()
operation 1
operation 2
operation 3
operation 4
...
operation n
End
Sub operation 1
on error goto errorhandling
errorhandling:
newthings
End sub
I dont think that would help, since operation 2 will be called whether or not there was an error in operation 1.
|
|
|
|