Load 3 user controls (web application) on their own threads - c#

I have 3 user controls that pull data from the database and display a gridview. I need all of these 3 gridviews to run at the same time.
How can I use threading to accomplish this?
I forgot to mention it is being developed in C#
Also, trying to create a thread in the page that is calling the 3 user controls is shutting down my localhost webserver whenever the thread is hit.
What is causing this?

Sorry for the late reply, hopefully I can still be helpful:
You probably want to look into ASP.NET async pages. There's a great writeup on MSDN Magazine: http://msdn.microsoft.com/en-us/magazine/cc163725.aspx
Almost half way down the page there's a header "Asynchronous Data Binding" that I believe addresses your issue.

Related

C# windows form browser control .DocumentCompleted event on .aspx pages

Before I go down the rabbit hole which is over my head and I would like to avoid for now… Is there a simple way to see if an online .aspx webpage loaded in the web browser control? .html pages work fine using .DocumentCompleted for me but .aspx visually loads fine but never triggers the DocumentCompleted event. I saw some good articles that mention the need of creating separate 3 threads and etc… unlike in those articles I am not interacting with the web application (the user is) I just want to hide a few irrelevant DIV elements on the side off the page.
user9938 Thank you! Unfortunately, I cannot mark your comment as an answer so I will post it for others here.
webview2 worked amazingly. On aspx pages NavigationCompleted still did not work however I was able to achieve this with CoreWebView2_DOMContentLoaded

Lazy loading and Telerik Reporting?

During recent weeks I have posted a number of questions regarding Telrik Reporting which of course come back with no response.. But fortunately, I managed all the matters. Now I ma going to raise another question and hope this one had some response.
The Question: There is a report which displays about 455 records. I am using MVC 3, WebApi and Telrik Reporting of course. I want to implement some kind of lazy loading. I explicitly mean, display records 30 by 30 on each page of telerik report viewer. That is to say, at first step only 30 records be loaded and if the user navigates to the next page, then another 30 records show up.
Can anyone give me a tip or solution how to handle this? Does telerik support something for that?
Thanks you
Actually, Telerik Report handle On demand Loading on every page for the client side of course. But at first it fetches all the data form the related data store. This is what I have got after days of researches and lots of efforts on this issue. Thus, decided to share it with others as no one comes to this questions with an answer! Hope it be helpful

Refreshing webform when database is externally updated

For experimental purposes i've made a ASP.net webform that writes to a database. Ive also made a windows form(c#) that writes to the same database.
The webform displays the text in a gridview and the winform displays the text in a datagridview.
My question is: is it possible to refresh the windows form and webform when the database is updated by the other? And if so, could anyone point me in the right direction?
George has suggested one good approach in his comment.
For ASP.Net, you could use SignalR to update the web page.
ASP.NET SignalR is a new library for ASP.NET developers that simplifies the process of adding real-time web functionality to your applications. Real-time web functionality is the ability to have server-side code push content to connected clients instantly as it becomes available.
The traditional approach would involve "polling" by the desktop app, that is, making a request every few seconds to see if there is new information. This approach can be resource-intense. You can also do polling from a web page, of course.
The simplest way to do this to use two timer controls, one in the WinForm and the other on the WebForm.
And at desired intervals just rebind the dataset.
Rebind Data
grdWaiver.DataSource = dv 'Set the dataview to the DataGrid
grdWaiver.DataBind()
(In above I used a dataview as a datasource)

How to display multiple pages under tabs similar to a Browser tab retaining loaded pages

We have an application where we have a single level navigation menu with some heavy-duty pages on each link. The user can switch back and forth between these pages frequently to obtain information that he needs.
Once the page gets generated, it wouldn't change for the session. However, the page is specific to the user, hence we cant cache it.
I was trying to come up with a solution where we generate the page once, and keep it hidden in the background until its link is clicked, but haven't been able to get my head around this.
One of the ways I thought was to have multiple div tags (one for each page) on one page and keep toggling the visibility as the links are pressed, but that would end up making this single page very heavy. Someone also suggested using iFrames, but I am not really comfortable using the iFrames much and I'm not even sure, if it would be any helpful either.
Can you guys please suggest a few approaches to tackle the issue?
update: Just to clarify, we are fine with keeping the pages separate and navigate across using a standard menu bar. We were just looking for ways to optimize the performance as we know that the pages once generated wouldn't change and there should be some way to tap that benefit.
You can use Ajax tab control for this purpose
Try taking a look at this MSDN article which specifically tackles the issue of how to user-level cache. Also, it might be more manageable to break each tab into a user control. That way your ASP.NET page has just the tab control and 1 user control for each section under the tab. It makes managing tabs much easier.
EDIT:
What I would do in your case, since you say the data won't change for the user, is I would grab the static data from the database and then I would store that data in the Session cache. THe session cache is specific per user and you can try to retrieve the static data from there instead of repetitively calling the database.
Check out the ASP Multiview control. Just remember that even though the different views are hidden when not active, their viewstate is still being sent back and forth. Can be a benefit if you need to check control values across views though.

How can I play with databinding to a desktop application like in web-based application

I've a form and I'm doing databinding of my datagridview in the event "form load", the problem is, that the form takes a little (or a lot depends on the size of information) to load, because my data has a lot of binary information (photos) to binding there.
In some sites, we can see a picture saying "loading", which is cool and is good to the user, because I knows that is loading and not stoped. So, I wanted to simulate something like that to desktop application when I'm doing databinding to the table, can you help me?
You can't do much about the actual binding itself, since forms have thread affinity. However, you can load the data (from the database or where-ever) on a separate thread - look at BackgroundWorker, for example.
If the db-load is fast, but the binding is slow, you can look at things like "virtual mode" that exists for many standard list-based controls. This can reduce the time taken to bind by only looking at the immediately visible data.
Other than that, you can do things like changing the cursor, showing a splash on another thread, etc. It really depends where the time is being spent (have you profiled?).
You could show the 'loading' form in a different thread.
Also consider hard whether you need all of the data loaded with the form - could any of this data be loaded after the form load?
Try and give your application a feeling of perceived speed.
Sometimes is not our decision to load the data after a user action. My client wants the data loaded without user action.
Thanks you for your answers :)

Categories