Advise on a class design using events and tasks to get data from webpages.

*class definition posted in comments

Basically, I'm trying to get data from Nasdaq.com website. There are 2 ways I want to use this class:

1.) a public constructor is passed a Stock object and that kicks off a a chain of actions:

-scraping webpage links from a datatable (spanning across many pages)

-each webpage link is opened and data from that page is stored in a List of dataObject.

-When list if dataobject is fully materialized, it is converted to a json string and a file is saved in a specific folder.

2.) Use a static method to create an instance of class using the private parameter-less constructor. This static method will get a list of strings which can be used to generate webpage urls without scraping the datatable. Then it's just a matter of opening each url and getting the data from that page. In this case no file is written.

It was working fine syncronously. To speed it up, I tried to use tasks and events and I'm sure I've ended up with unnecessarily complications. So I'm wondering what are some ways to improve this?

by pope_says via /r/csharp

Leave a Reply