473,387 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

c++ event sink

I have a function that will download XML from internet and load XML
data into database.

The function will take 5 - 20 minutes to finish.

I heard I should use event sink (event listener) when function is
finished the task, then it will notify the caller.

So I am planning to create a seperate thread to do the long XML
loading function by using - _beginthreadex()

But how to create a notification / event sink / event listener in C++?

any library can easily just a library function call?

or any sample source code on the internet?

Thanks
Jun 27 '08 #1
9 3593
Sam
Eric Kaplan writes:
I heard I should use event sink (event listener) when function is
finished the task, then it will notify the caller.

So I am planning to create a seperate thread to do the long XML
loading function by using - _beginthreadex()

But how to create a notification / event sink / event listener in C++?
There's no such thing as a "notification", an "event sink", or an "event
listener", in the C++ programming language.

You must be referring to objects, or APIs, that are particular to whatever
operating system you are using.

You have a better chance of finding a helpful answer to your question if you
ask, instead, on a different newsgroup that's specific to whatever operating
system or library that you are using.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQBIATtex9p3GYHlUOIRAjhcAJ94mbaefTJI9hrDvjxnDf DcWxizYgCfYAfy
tb/KKifAaN9arrDj/hA0FHo=
=kw0k
-----END PGP SIGNATURE-----

Jun 27 '08 #2
* Eric Kaplan:
I have a function that will download XML from internet and load XML
data into database.

The function will take 5 - 20 minutes to finish.

I heard I should use event sink (event listener) when function is
finished the task, then it will notify the caller.

So I am planning to create a seperate thread to do the long XML
loading function by using - _beginthreadex()
Why not a separate process?

Perhaps the user wants to terminate the UI part, but wants the download to complete.

But how to create a notification / event sink / event listener in C++?
If you have a GUI then you (probably) already have such functionality.

But anyway take a look at e.g. Boost slots.

any library can easily just a library function call?
Huh.

or any sample source code on the internet?
Extremely much. Go look. :-)
Cheers, & hth.,

- Alf
Jun 27 '08 #3

that's a very good point, how to start a seperate process from the
code?

and how can I notify the caller when the process is finished?
>
Why not a separate process?
Jun 27 '08 #4
* Eric Kaplan:
that's a very good point, how to start a seperate process from the
code?
In standard C++ and C all you have is the 'system' function, which is not
adequate for your purposes.

Essentially the question is therefore environment-specific, with best answers in
an environment-specific group.

The FAQ lists a few such groups.

and how can I notify the caller when the process is finished?
Again, system-specific. E.g., in Windows, which is what I know best, you can
use mailslots (which are essentially datagrams camouflaged via file
abstraction), pipes, any waitable global object, socket programming, real files,
higher level COM object, message queues, window messages, and more, it's like
they say just your fantasy that sets the limits, but it's all off-topic here in
clc++, sorry!
Cheers, & hth.,

- Alf
Jun 27 '08 #5

"Eric Kaplan" <to*********@yahoo.comwrote in message
>I have a function that will download XML from internet and load XML
data into database.

The function will take 5 - 20 minutes to finish.

I heard I should use event sink (event listener) when function is
finished the task, then it will notify the caller.

So I am planning to create a seperate thread to do the long XML
loading function by using - _beginthreadex()
There is no concept of thread or process as far as the C++ language is
concerned. People would scream your question as OT here :-). You should try
your platform specific newsgroup.
But how to create a notification / event sink / event listener in C++?

any library can easily just a library function call?

or any sample source code on the internet?
Search engines are your friend.
--
http://techytalk.googlepages.com
Jun 27 '08 #6

"Stefan Ram" <ra*@zedat.fu-berlin.dewrote in message
"sk_usenet" <sometechyguy at gmail dot comwrites:
>>There is no concept of thread or process as far as the C++
language is concerned.

»When an exception is thrown, control is transferred to
the nearest handler with a matching type (15.3); "nearest"
means the handler for which the compound-statement,
ctor-initializer, or function-body following the try
keyword was most recently entered by the thread of control
and not yet exited.« ¯¯¯¯¯¯

ISO/IEC 14882:2003(E), 15.1p2

»If a function is registered with atexit (see <cstdlib>,
18.3) then following the call to exit, any objects with
static storage duration initialized prior to the
registration of that function shall not be destroyed until
the registered function is called from the termination
process and has completed.«
¯¯¯¯¯¯¯
ISO/IEC 14882:2003(E), 3.6.3p3
Ok, pedantically speaking Standard does recognize something of a thread, and
something of a process. But the bottom line is that OP's question was
off-topic.
Jun 27 '08 #7
Thanks your hint!

but i think it may not be a good idea to use such big library for a
small task.

Does using call back function a good idea in here? (loading XML to
DB, after finish, notify the main / primary thread)


>Read http://libsigc.sourceforge.net/
Jun 27 '08 #9
On Apr 13, 4:39 am, Eric Kaplan <tobycraf...@yahoo.comwrote:
Thanks your hint!

but i think it may not be a good idea to use such big library for a
small task.

Does using call back function a good idea in here? (loading XML to
DB, after finish, notify the main / primary thread)
Readhttp://libsigc.sourceforge.net/
I believe you can also use the boost::bind library (http://
http://www.boost.org/doc/libs/1_35_0...bind/bind.html) to create the sort
of callbacks you would be interested in.

You might also want to take a look at the
dlib::member_function_pointer object which is similar but may be
easier to use depending on what you are trying to accomplish. See,
http://dclib.sourceforge.net/other.h...nction_pointer and
http://dclib.sourceforge.net/member_...er_ex.cpp.html

-Davis
Jun 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: BlueMonkMN | last post by:
I've been trying to think of the right way to design relationships between objects with different desired lifetimes that raise events. If an event source is a relatively permanent object and the...
1
by: Bob Whiton | last post by:
I have an unmanaged class which has a member variable: gcroot<DataTable*> myDataTable; I would like to sink the RowDeleting event in my UNmanaged class. However, I can't declare an event...
0
by: Arnaud Debaene | last post by:
Hello all. I've got a bunch of existing, non managed, C++ DLLs that export types with, among other things, public events implemented using the boost::signals library. Now, I need to have...
0
by: techie | last post by:
I have created an event sink in my ATL COM project. The event sink receives events from a C# component. There is no problem with receving events but when my COM object is released I get an access...
6
by: Charles Law | last post by:
I have a class, which implements an interface. Let's say, that the interface looks something like Public Interface IEventSinks Sub ValueChanged(sender As Object, e As ValueChangedEventArgs) Sub...
6
by: utkarsh | last post by:
Hi All, I am using the following method "FireAsync" (i got the following information from the google groups) to fire the event for all the subscribers. Is there another way to fire the event...
7
by: Don | last post by:
Getting errors after following the MSDN article on using VB.NET (and VS2005) for "Implementing a Managed OnSave Event Sink" for Exchange Server 2007. Not sure, but part of the problem may be that...
1
by: mooni | last post by:
Hi all, I am trying to create a class that will act as event sink to a COM object. Just to tell you the COM object is SoftUSBEndpoint which is part of Device Simulation Framework. Anyways its...
5
by: =?Utf-8?B?Q29kZVJhem9y?= | last post by:
I have an event sink which does some work to the software we use, according to the data contained within an email. This is all working hunky dory. What i want to know is whether it is possible to...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.