Home All Groups Group Topic Archive Search About

Stop loading data process

Author
2 Mar 2007 6:40 AM
Badis
Hi

I have an application that search and load data from database and display it
on the screen.
because sometimes it takes too much time. I want to create a button on the
search screen (like the stop button in the web browser) that will allow me to
stop the searching process, gain back the focus and search for something else.
How to do that...!?? the issue is that if the computer screen itself is
locked during the search process!! how can the user gain back the ability to
click the stop button?

Cheers.

Author
2 Mar 2007 1:53 PM
RickHodder
Hi Badis

To achieve what you want you  need to move the code that loads the data into
a separate thread.

It is fairly easy to do this if you are using .NET 2.0,because there is a
component called BackgroundWorker. You can drop this component on a form or
user control, put the data-loading control into an event called DoWork: the
code will run in a separate thread.

It also has a ProgressChanged event, which can be used to send progress
information from the thread back to the form/control. The event argument for
this event has a property called ProgressPercentage that lets the separate
thread tell the form the % complete. For example, you could have a progress
thermometer on the form,which could use this event to show how much of the
loading process has completed.

It also has a RunWorkCompleted event that fires when the code running on the
separate thread has completed, and even has properties that tell you whether
it ended normally, or was cancelled

Hope this helped
--
Rick Hodder


Show quoteHide quote
"Badis" wrote:

> Hi
>
> I have an application that search and load data from database and display it
> on the screen.
> because sometimes it takes too much time. I want to create a button on the
> search screen (like the stop button in the web browser) that will allow me to
> stop the searching process, gain back the focus and search for something else.
> How to do that...!?? the issue is that if the computer screen itself is
> locked during the search process!! how can the user gain back the ability to
> click the stop button?
>
> Cheers.
>
Author
2 Mar 2007 2:34 PM
Bob Butler
"RickHodder" <RickHod***@discussions.microsoft.com> wrote in message
news:44D6ECDB-7FB0-4930-9A0B-41AD931CF7F1@microsoft.com
> Hi Badis
>
> To achieve what you want you  need to move the code that loads the
> data into a separate thread.

That's one approach but is hardly the only one.  It's fairly easy in VB 6 to
use DoEvents or the related API calls to allow a button to be clicked.  By
setting a flag in the click event the processing routine can abort when it
see the flag.

--
Reply to the group so all can participate
VB.Net: "Fool me once..."
Author
3 Mar 2007 1:58 PM
Badis
I'm not that familliar with APIs or DoEvents could pls be specific. A simple
code will really help.



Show quoteHide quote
"Bob Butler" wrote:

> "RickHodder" <RickHod***@discussions.microsoft.com> wrote in message
> news:44D6ECDB-7FB0-4930-9A0B-41AD931CF7F1@microsoft.com
> > Hi Badis
> >
> > To achieve what you want you  need to move the code that loads the
> > data into a separate thread.
>
> That's one approach but is hardly the only one.  It's fairly easy in VB 6 to
> use DoEvents or the related API calls to allow a button to be clicked.  By
> setting a flag in the click event the processing routine can abort when it
> see the flag.
>
> --
> Reply to the group so all can participate
> VB.Net: "Fool me once..."
>
>
Author
5 Mar 2007 3:56 PM
RickHodder
Bob,

First of all let me apologize for giving a .NET answer in the vb classic
area. I was just trying to help, and when searching through the loads of
newsgroups I chose the wrong one.

> That's one approach but is hardly the only one

I think you misunderstood me. I didnt claim that this was the only approach.
But in fact if vb6 developers move into .NET, the approach I presented is
totally valid.

Rick
--
Rick Hodder


Show quoteHide quote
"Bob Butler" wrote:

> "RickHodder" <RickHod***@discussions.microsoft.com> wrote in message
> news:44D6ECDB-7FB0-4930-9A0B-41AD931CF7F1@microsoft.com
> > Hi Badis
> >
> > To achieve what you want you  need to move the code that loads the
> > data into a separate thread.
>
> That's one approach but is hardly the only one.  It's fairly easy in VB 6 to
> use DoEvents or the related API calls to allow a button to be clicked.  By
> setting a flag in the click event the processing routine can abort when it
> see the flag.
>
> --
> Reply to the group so all can participate
> VB.Net: "Fool me once..."
>
>
Author
5 Mar 2007 4:25 PM
Robert Morley
> First of all let me apologize for giving a .NET answer in the vb classic
> area. I was just trying to help, and when searching through the loads of
> newsgroups I chose the wrong one.

Hehehe...it happens.  As you may have noticed, many people around here often
pull out various firearms and such at even the mention of the word ".NET".
:)  As much as I dislike VB.NET (and at the risk of getting myself
ostracized and/or shot), I often wonder if we wouldn't have saved ourselves
a lot of headaches by just having the VB groups be catch-alls and
determining version as part of each thread (kinda like we do for VB6 vs.
VB5).  I can certainly see arguments against that philosophy, but I still
think it might've worked out better in some ways.  Ah well, what's done is
done. :)



Rob
Author
6 Mar 2007 8:06 AM
J French
On Mon, 5 Mar 2007 11:25:56 -0500, "Robert Morley"
<rmor***@magma.ca.N0.Freak1n.sparn> wrote:

>> First of all let me apologize for giving a .NET answer in the vb classic
>> area. I was just trying to help, and when searching through the loads of
>> newsgroups I chose the wrong one.
>
>Hehehe...it happens.  As you may have noticed, many people around here often
>pull out various firearms and such at even the mention of the word ".NET".
>:)  As much as I dislike VB.NET (and at the risk of getting myself
>ostracized and/or shot), I often wonder if we wouldn't have saved ourselves
>a lot of headaches by just having the VB groups be catch-alls and
>determining version as part of each thread (kinda like we do for VB6 vs.
>VB5).  I can certainly see arguments against that philosophy, but I still
>think it might've worked out better in some ways.  Ah well, what's done is
>done. :)

It would not work, quite often it is almost impossible to work out
whether a question is Fred.Net or VB Classic

- it would really confuse newbies - and everyone else

Anyway, they have a load of  dotnet  NGs
- let them use them, and not foul up our play pen
Author
6 Mar 2007 5:45 PM
Robert Morley
You have a point about the newbies, especially, and certainly since there
are already a bunch of dotnet newsgroups, I'm more than happy to keep them
separate.  I think it would be even better if we could simply abandon the
"vb" newsgroups in favour of a set of "vbclassic" newsgroups, but I
recognize the utter futility of trying to do that. :)


Rob

Show quoteHide quote
"J French" <erew***@nowhere.uk> wrote in message
news:45ed206b.3894846@news.btopenworld.com...
> On Mon, 5 Mar 2007 11:25:56 -0500, "Robert Morley"
> <rmor***@magma.ca.N0.Freak1n.sparn> wrote:
>
>>> First of all let me apologize for giving a .NET answer in the vb classic
>>> area. I was just trying to help, and when searching through the loads of
>>> newsgroups I chose the wrong one.
>>
>>Hehehe...it happens.  As you may have noticed, many people around here
>>often
>>pull out various firearms and such at even the mention of the word ".NET".
>>:)  As much as I dislike VB.NET (and at the risk of getting myself
>>ostracized and/or shot), I often wonder if we wouldn't have saved
>>ourselves
>>a lot of headaches by just having the VB groups be catch-alls and
>>determining version as part of each thread (kinda like we do for VB6 vs.
>>VB5).  I can certainly see arguments against that philosophy, but I still
>>think it might've worked out better in some ways.  Ah well, what's done is
>>done. :)
>
> It would not work, quite often it is almost impossible to work out
> whether a question is Fred.Net or VB Classic
>
> - it would really confuse newbies - and everyone else
>
> Anyway, they have a load of  dotnet  NGs
> - let them use them, and not foul up our play pen
>
>
Author
6 Mar 2007 7:18 PM
Bob O`Bob
Robert Morley wrote:
> You have a point about the newbies, especially, and certainly since there
> are already a bunch of dotnet newsgroups, I'm more than happy to keep them
> separate.  I think it would be even better if we could simply abandon the
> "vb" newsgroups in favour of a set of "vbclassic" newsgroups, but I
> recognize the utter futility of trying to do that. :)


there's a dozen or so good reasons, and in my opinion the chief among them
is the loss of search engine (e.g. google groups) continuity.

It would be like trying to rewrite history.
(not impossible, but a lot harder now that there's a worldwide Internet)


    Bob
--
Author
6 Mar 2007 8:31 PM
Robert Morley
I tend to forget about google groups, but yeah, that would be another very
good reason not to.  I guess the way I look at it is "in an ideal world, we
could all just migrate over and there would be a minimum of problems", but
I'm all too aware that the world isn't ideal. :)


Rob

Show quoteHide quote
"Bob O`Bob" <filter***@yahoogroups.com> wrote in message
news:O1%238xQCYHHA.4396@TK2MSFTNGP06.phx.gbl...
> Robert Morley wrote:
>> You have a point about the newbies, especially, and certainly since there
>> are already a bunch of dotnet newsgroups, I'm more than happy to keep
>> them separate.  I think it would be even better if we could simply
>> abandon the "vb" newsgroups in favour of a set of "vbclassic" newsgroups,
>> but I recognize the utter futility of trying to do that. :)
>
>
> there's a dozen or so good reasons, and in my opinion the chief among them
> is the loss of search engine (e.g. google groups) continuity.
>
> It would be like trying to rewrite history.
> (not impossible, but a lot harder now that there's a worldwide Internet)
>
>
> Bob
> --
Author
6 Mar 2007 8:55 PM
Bob Butler
"Robert Morley" <rmor***@magma.ca.N0.Freak1n.sparn> wrote in message
news:uEqBL$CYHHA.4940@TK2MSFTNGP05.phx.gbl
> I tend to forget about google groups, but yeah, that would be another
> very good reason not to.  I guess the way I look at it is "in an
> ideal world, we could all just migrate over and there would be a
> minimum of problems", but I'm all too aware that the world isn't
> ideal. :)

In an ideal world we'd have a migration path for VB 6.0 applications

--
Reply to the group so all can participate
VB.Net: "Fool me once..."
Author
6 Mar 2007 8:58 PM
Robert Morley
Hahaha...TOO true!



Rob

Show quoteHide quote
"Bob Butler" <tiredofit@nospam.ever> wrote in message
news:uPKGCHDYHHA.1296@TK2MSFTNGP02.phx.gbl...
> "Robert Morley" <rmor***@magma.ca.N0.Freak1n.sparn> wrote in message
> news:uEqBL$CYHHA.4940@TK2MSFTNGP05.phx.gbl
>> I tend to forget about google groups, but yeah, that would be another
>> very good reason not to.  I guess the way I look at it is "in an
>> ideal world, we could all just migrate over and there would be a
>> minimum of problems", but I'm all too aware that the world isn't
>> ideal. :)
>
> In an ideal world we'd have a migration path for VB 6.0 applications
>
> --
> Reply to the group so all can participate
> VB.Net: "Fool me once..."
>
Author
6 Mar 2007 11:21 PM
Bob O`Bob
Bob Butler wrote:
> "Robert Morley" <rmor***@magma.ca.N0.Freak1n.sparn> wrote in message
> news:uEqBL$CYHHA.4940@TK2MSFTNGP05.phx.gbl
>> I tend to forget about google groups, but yeah, that would be another
>> very good reason not to.  I guess the way I look at it is "in an
>> ideal world, we could all just migrate over and there would be a
>> minimum of problems", but I'm all too aware that the world isn't
>> ideal. :)
>
> In an ideal world we'd have a migration path for VB 6.0 applications
>


Yup.  And a lot less need for separate newsgroups.
Author
7 Mar 2007 7:40 AM
J French
On Tue, 6 Mar 2007 12:45:02 -0500, "Robert Morley"
<rmor***@magma.ca.N0.Freak1n.sparn> wrote:

>You have a point about the newbies, especially, and certainly since there
>are already a bunch of dotnet newsgroups, I'm more than happy to keep them
>separate.  I think it would be even better if we could simply abandon the
>"vb" newsgroups in favour of a set of "vbclassic" newsgroups, but I
>recognize the utter futility of trying to do that. :)

I see that you are coming round to our way of thinking
- which is basically to make the best of what we have got
Author
7 Mar 2007 6:01 PM
Robert Morley
>>You have a point about the newbies, especially, and certainly since there
>>are already a bunch of dotnet newsgroups, I'm more than happy to keep them
>>separate.  I think it would be even better if we could simply abandon the
>>"vb" newsgroups in favour of a set of "vbclassic" newsgroups, but I
>>recognize the utter futility of trying to do that. :)
>
> I see that you are coming round to our way of thinking
> - which is basically to make the best of what we have got

I wouldn't say "coming round to" (partly because I'm Canadian, where we say
"coming *a*round to" <g>), so much as I've always acknowledged the inherent
problems and just wish it could've been different.  As you say, this is what
we've got, so let's make the best of it.



Rob
Author
7 Mar 2007 7:43 PM
Bob O`Bob
Robert Morley wrote:

> I wouldn't say "coming round to" (partly because I'm Canadian, where we say
> "coming *a*round to" <g>), so much as I've always acknowledged the inherent
> problems and just wish it could've been different.  As you say, this is what
> we've got, so let's make the best of it.


shouldn't that be "coming *eh*round to"?
Author
7 Mar 2007 11:49 PM
Robert Morley
No no no, "eh" is usually used at the end of a sentence.  It's become far
less common in the 90's and 00's than it used to be, though it's still
used...kind of like punctuating sentences with "like".

So, like, you see my point, eh? <g>



Rob

Show quoteHide quote
"Bob O`Bob" <filter***@yahoogroups.com> wrote in message
news:OTFnZDPYHHA.1300@TK2MSFTNGP02.phx.gbl...
> Robert Morley wrote:
>
>> I wouldn't say "coming round to" (partly because I'm Canadian, where we
>> say "coming *a*round to" <g>), so much as I've always acknowledged the
>> inherent problems and just wish it could've been different.  As you say,
>> this is what we've got, so let's make the best of it.
>
>
> shouldn't that be "coming *eh*round to"?
Author
8 Mar 2007 8:46 AM
J French
On Wed, 7 Mar 2007 13:01:13 -0500, "Robert Morley"
<rmor***@magma.ca.N0.Freak1n.sparn> wrote:

>>>You have a point about the newbies, especially, and certainly since there
>>>are already a bunch of dotnet newsgroups, I'm more than happy to keep them
>>>separate.  I think it would be even better if we could simply abandon the
>>>"vb" newsgroups in favour of a set of "vbclassic" newsgroups, but I
>>>recognize the utter futility of trying to do that. :)
>>
>> I see that you are coming round to our way of thinking
>> - which is basically to make the best of what we have got

>I wouldn't say "coming round to" (partly because I'm Canadian, where we say
>"coming *a*round to" <g>), so much as I've always acknowledged the inherent
>problems and just wish it could've been different.  As you say, this is what
>we've got, so let's make the best of it.

I think you are going to find these NGs very interesting
- we may look like a bunch of old bigots, but there is a lot of
experience around here, we tend to have individual specialities

I rather suspect that we get more out of VB than most people at MS
expected
Author
8 Mar 2007 4:10 PM
Robert Morley
Yup, you do look like a bunch of old bigots, so I'll probably fit right in,
because as we all know, Access' GUI (especially the form designer) is miles
ahead of VB6's <eg>, and .NET's GUI is an utter disaster, or at least it was
the last time I checked it out.  But I'm here for the experience, and have
my own to contribute...though I don't think I would've ever come up with a
one-line function to display a byte in binary format! :P


Rob

Show quoteHide quote
"J French" <erew***@nowhere.uk> wrote in message
news:45efcca0.2814526@news.btopenworld.com...
> On Wed, 7 Mar 2007 13:01:13 -0500, "Robert Morley"
> <rmor***@magma.ca.N0.Freak1n.sparn> wrote:
>
>>>>You have a point about the newbies, especially, and certainly since
>>>>there
>>>>are already a bunch of dotnet newsgroups, I'm more than happy to keep
>>>>them
>>>>separate.  I think it would be even better if we could simply abandon
>>>>the
>>>>"vb" newsgroups in favour of a set of "vbclassic" newsgroups, but I
>>>>recognize the utter futility of trying to do that. :)
>>>
>>> I see that you are coming round to our way of thinking
>>> - which is basically to make the best of what we have got
>
>>I wouldn't say "coming round to" (partly because I'm Canadian, where we
>>say
>>"coming *a*round to" <g>), so much as I've always acknowledged the
>>inherent
>>problems and just wish it could've been different.  As you say, this is
>>what
>>we've got, so let's make the best of it.
>
> I think you are going to find these NGs very interesting
> - we may look like a bunch of old bigots, but there is a lot of
> experience around here, we tend to have individual specialities
>
> I rather suspect that we get more out of VB than most people at MS
> expected
Author
9 Mar 2007 8:38 AM
J French
On Thu, 8 Mar 2007 11:10:04 -0500, "Robert Morley"
<rmor***@magma.ca.N0.Freak1n.sparn> wrote:

>Yup, you do look like a bunch of old bigots, so I'll probably fit right in,
>because as we all know, Access' GUI (especially the form designer) is miles
>ahead of VB6's <eg>, and .NET's GUI is an utter disaster, or at least it was
>the last time I checked it out.  But I'm here for the experience, and have
>my own to contribute...though I don't think I would've ever come up with a
>one-line function to display a byte in binary format! :P

Ah, one liners are Rick's speciality
- horrible things, but he likes to show that they can be done
- not that I think /anyone/ should use them in production code

With VB you'll need to decide how much you want to rely on 3rd party
controls - I'm strongly biased against NMH (Not Made Here) stuff

I've no real feelings about .NET, although I resent the use of VB in
its name and the suggestion that we are a bunch of whingers.

Personally I reckon that there is a lot of life left in VB Classic, if
it ceases to work in later releases of Windows then so will many other
things - and that would be a problem for MS
Author
9 Mar 2007 5:00 PM
Karl E. Peterson
J French <erew***@nowhere.uk> wrote:
> Personally I reckon that there is a lot of life left in VB Classic, if
> it ceases to work in later releases of Windows then so will many other
> things - and that would be a problem for MS

Same opinion here, fwiw.
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
2 Mar 2007 8:05 PM
Jeff Johnson
"RickHodder" <RickHod***@discussions.microsoft.com> wrote in message
news:44D6ECDB-7FB0-4930-9A0B-41AD931CF7F1@microsoft.com...

> It is fairly easy to do this if you are using .NET 2.0

[Canned response]
This is a VB "classic" newsgroup. Questions (or in this case, ANSWERS!)
about VB.NET (including VB 2005, which has dropped .NET from its name) are
off-topic here.

Please ask .NET questions in newsgroups with "dotnet" in their names. The
*.vb.* groups are for VB6 and earlier. If you don't see the *.dotnet.*
groups on your news server, connect directly to the Microsoft server:
msnews.microsoft.com.

For questions specific to the VB.NET language, use this group:
microsoft.public.dotnet.languages.vb

Please note that things like controls and data access, which have their own
subgroups in the Classic VB hierarchy, are not language-specific in .NET, so
you should look for groups like these:
microsoft.public.dotnet.framework.windowsforms.controls
microsoft.public.dotnet.framework.adonet
(Note that "vb" is not present in the group name.)
Author
2 Mar 2007 8:14 PM
Bob O`Bob
Jeff Johnson wrote:
> "RickHodder" <RickHod***@discussions.microsoft.com> wrote in message
> news:44D6ECDB-7FB0-4930-9A0B-41AD931CF7F1@microsoft.com...
>
>> It is fairly easy to do this if you are using .NET 2.0
>
> [Canned response]
> This is a VB "classic" newsgroup. Questions (or in this case, ANSWERS!)
> about VB.NET (including VB 2005, which has dropped .NET from its name) are
> off-topic here.
>
> Please ask .NET questions in newsgroups with "dotnet" in their names. The


   ... or supply .NET answers ...


Show quoteHide quote
> *.vb.* groups are for VB6 and earlier. If you don't see the *.dotnet.*
> groups on your news server, connect directly to the Microsoft server:
> msnews.microsoft.com.
>
> For questions specific to the VB.NET language, use this group:
> microsoft.public.dotnet.languages.vb
>
> Please note that things like controls and data access, which have their own
> subgroups in the Classic VB hierarchy, are not language-specific in .NET, so
> you should look for groups like these:
> microsoft.public.dotnet.framework.windowsforms.controls
> microsoft.public.dotnet.framework.adonet
> (Note that "vb" is not present in the group name.)
>
>
Author
2 Mar 2007 9:45 PM
Jeff Johnson
"Bob O`Bob" <filter***@yahoogroups.com> wrote in message
news:%23wItrdQXHHA.528@TK2MSFTNGP03.phx.gbl...

>> [Canned response]
>> This is a VB "classic" newsgroup. Questions (or in this case, ANSWERS!)
>> about VB.NET (including VB 2005, which has dropped .NET from its name)
>> are off-topic here.
>>
>> Please ask .NET questions in newsgroups with "dotnet" in their names. The
>
>
>   ... or supply .NET answers ...

See the first line. (The response was slightly "un-canned.")
Author
3 Mar 2007 9:45 AM
Bob O`Bob
Jeff Johnson wrote:
Show quoteHide quote
> "Bob O`Bob" <filter***@yahoogroups.com> wrote in message
> news:%23wItrdQXHHA.528@TK2MSFTNGP03.phx.gbl...
>
>>> [Canned response]
>>> This is a VB "classic" newsgroup. Questions (or in this case, ANSWERS!)
>>> about VB.NET (including VB 2005, which has dropped .NET from its name)
>>> are off-topic here.
>>>
>>> Please ask .NET questions in newsgroups with "dotnet" in their names. The
>>
>>   ... or supply .NET answers ...
>
> See the first line. (The response was slightly "un-canned.")
>
>


Oh, you're right.  See what I get for recognizing and skimming?
Author
5 Mar 2007 3:46 PM
RickHodder
Thanks for the direction Jeff!

--
Rick Hodder


Show quoteHide quote
"Jeff Johnson" wrote:

> "RickHodder" <RickHod***@discussions.microsoft.com> wrote in message
> news:44D6ECDB-7FB0-4930-9A0B-41AD931CF7F1@microsoft.com...
>
> > It is fairly easy to do this if you are using .NET 2.0
>
> [Canned response]
> This is a VB "classic" newsgroup. Questions (or in this case, ANSWERS!)
> about VB.NET (including VB 2005, which has dropped .NET from its name) are
> off-topic here.
>
> Please ask .NET questions in newsgroups with "dotnet" in their names. The
> *.vb.* groups are for VB6 and earlier. If you don't see the *.dotnet.*
> groups on your news server, connect directly to the Microsoft server:
> msnews.microsoft.com.
>
> For questions specific to the VB.NET language, use this group:
> microsoft.public.dotnet.languages.vb
>
> Please note that things like controls and data access, which have their own
> subgroups in the Classic VB hierarchy, are not language-specific in .NET, so
> you should look for groups like these:
> microsoft.public.dotnet.framework.windowsforms.controls
> microsoft.public.dotnet.framework.adonet
> (Note that "vb" is not present in the group name.)
>
>
>
Author
3 Mar 2007 2:08 PM
Badis
Thks very much Rick, but guys; my question is in vb6.
Sorry for the stupid question, but how can I separate the loading process in
a separate thread!? do you mean in a separate function!!? and how could that
help if the screen itself is lock during the loading process!!!!?



Show quoteHide quote
"RickHodder" wrote:

> Hi Badis
>
> To achieve what you want you  need to move the code that loads the data into
> a separate thread.
>
> It is fairly easy to do this if you are using .NET 2.0,because there is a
> component called BackgroundWorker. You can drop this component on a form or
> user control, put the data-loading control into an event called DoWork: the
> code will run in a separate thread.
>
> It also has a ProgressChanged event, which can be used to send progress
> information from the thread back to the form/control. The event argument for
> this event has a property called ProgressPercentage that lets the separate
> thread tell the form the % complete. For example, you could have a progress
> thermometer on the form,which could use this event to show how much of the
> loading process has completed.
>
> It also has a RunWorkCompleted event that fires when the code running on the
> separate thread has completed, and even has properties that tell you whether
> it ended normally, or was cancelled
>
> Hope this helped
> --
> Rick Hodder
>
>
> "Badis" wrote:
>
> > Hi
> >
> > I have an application that search and load data from database and display it
> > on the screen.
> > because sometimes it takes too much time. I want to create a button on the
> > search screen (like the stop button in the web browser) that will allow me to
> > stop the searching process, gain back the focus and search for something else.
> > How to do that...!?? the issue is that if the computer screen itself is
> > locked during the search process!! how can the user gain back the ability to
> > click the stop button?
> >
> > Cheers.
> >