How to improve listbox databind in WIndows Mobile 6
-
Hi! I started a development of a application (in Windows Mobile 6) and now i have a little problem: My datasource have 11.000~12.000 registers and when I bind it to my ListBox, this action spend 6 seconds (I think its a lot) and now I want to reduce that time. Anyone now a way to do this? Some code to exemplify my situation:
SQLiteConnection cnn = openCon();
string SQL = "select cod, desc from produtcs";
SQLiteDataReader sDR;
List<MyObj> data = new List<MyObj>();
cnn.Open();// execution time: 1 second
SQLiteCommand sCommand = new SQLiteCommand(SQL, cnn);
sDR = sCommand.ExecuteReader();// execution time: 5~6 seconds
while (sDR.Read())
{
data.Add(new MyObj(sDR["cod"].ToString(), sDR["desc"].ToString()));
}// execution time: 6 seconds
listBox1.DataSource = data;I need populate MyObj after, cuz this I use the variable "data"
class MyObj
{
public MyObj(int p1, string p2){ ... }
private int cod;
private string desc;
private string ...
private int ...// set and get methods // ...
}
[]'s Eder Sá
[]'s
-
Hi! I started a development of a application (in Windows Mobile 6) and now i have a little problem: My datasource have 11.000~12.000 registers and when I bind it to my ListBox, this action spend 6 seconds (I think its a lot) and now I want to reduce that time. Anyone now a way to do this? Some code to exemplify my situation:
SQLiteConnection cnn = openCon();
string SQL = "select cod, desc from produtcs";
SQLiteDataReader sDR;
List<MyObj> data = new List<MyObj>();
cnn.Open();// execution time: 1 second
SQLiteCommand sCommand = new SQLiteCommand(SQL, cnn);
sDR = sCommand.ExecuteReader();// execution time: 5~6 seconds
while (sDR.Read())
{
data.Add(new MyObj(sDR["cod"].ToString(), sDR["desc"].ToString()));
}// execution time: 6 seconds
listBox1.DataSource = data;I need populate MyObj after, cuz this I use the variable "data"
class MyObj
{
public MyObj(int p1, string p2){ ... }
private int cod;
private string desc;
private string ...
private int ...// set and get methods // ...
}
[]'s Eder Sá
[]'s
Eder Sa wrote:
Anyone know a way to do this?
First place to start would be asking in the correct forum. See Mobile[^] Reduce the amount of data you are trying to display. Users are not going to scroll through 12,000 items, particularly on a mobile device.
I know the language. I've read a book. - _Madmatt
-
Eder Sa wrote:
Anyone know a way to do this?
First place to start would be asking in the correct forum. See Mobile[^] Reduce the amount of data you are trying to display. Users are not going to scroll through 12,000 items, particularly on a mobile device.
I know the language. I've read a book. - _Madmatt
My first post and my first mistake. :sigh: I need to load all the data, because when the user types some letters in a filter, the focus moves in the list, searching for the first ocorrence (I use a binary search, but modified and it works fine!) I can move the topic to Mobile Forum?
[]'s
-
My first post and my first mistake. :sigh: I need to load all the data, because when the user types some letters in a filter, the focus moves in the list, searching for the first ocorrence (I use a binary search, but modified and it works fine!) I can move the topic to Mobile Forum?
[]'s
It's too late to move the post now. Populate the list after you have filtered the data.
I know the language. I've read a book. - _Madmatt
-
My first post and my first mistake. :sigh: I need to load all the data, because when the user types some letters in a filter, the focus moves in the list, searching for the first ocorrence (I use a binary search, but modified and it works fine!) I can move the topic to Mobile Forum?
[]'s
Eder Sa wrote:
I need to load all the data, because
How many entries will the user see when typing? Fetch the top 20 and display that until the user hits enter - and page the rest. Google wouldn't be very efficient if it had to send you all it's search-results and let your browser filter it. Imagine that, with IE4.
I are Troll :suss:
-
Eder Sa wrote:
I need to load all the data, because
How many entries will the user see when typing? Fetch the top 20 and display that until the user hits enter - and page the rest. Google wouldn't be very efficient if it had to send you all it's search-results and let your browser filter it. Imagine that, with IE4.
I are Troll :suss:
-
I implemented your suggestion and like the result. I need to do some more tests and I back later with feedback. Thx!
[]'s
-
Eder Sa wrote:
I need to load all the data, because
How many entries will the user see when typing? Fetch the top 20 and display that until the user hits enter - and page the rest. Google wouldn't be very efficient if it had to send you all it's search-results and let your browser filter it. Imagine that, with IE4.
I are Troll :suss:
Bad news X| I tried use the suggested method and the result of the test in a device (HTC Touch2) is a desaster! The device spend much time running SQLs when I use "like" (about 1~2 seconds). If the user type 100 characters, the total time of the operations is about 100~200 seconds. (not a good result) I did more tests in the device, and the results are worst. Look:
SQLiteConnection cnn = openCon();
string SQL = "select cod, desc from produtcs";
SQLiteDataReader sDR;
List<MyObj> data = new List<MyObj>();
cnn.Open();// execution time: 1 second (emulator)
// execution time: 1~2 second (device)
SQLiteCommand sCommand = new SQLiteCommand(SQL, cnn);
sDR = sCommand.ExecuteReader();// execution time: 5~6 seconds (emulator)
// execution time: 18~20 seconds (device)
// alternative test: 1 seconds (emulator)
// alternative test: 6 seconds (device)
while (sDR.Read())
{
data.Add(new MyObj(Convert.ToInt32(sDR["cod"].ToString()), sDR["desc"].ToString()));
// Alternative test inserting null objects
// data.Add(new MyObj());
}// execution time: 6 seconds (emulator)
// execution time: 18 seconds (device)
// same times with alternative data
listBox1.DataSource = data;// with GRID VIEW
// execution time: 0 seconds (emulator)
// execution time: 0 seconds (device)
dataGrid1.DataSource = data;Now I'll try make it without use a List<> and insert direclty in a listBox. At the moment the best solution. I post my feedback later.
[]'s Eder Sá
-
Bad news X| I tried use the suggested method and the result of the test in a device (HTC Touch2) is a desaster! The device spend much time running SQLs when I use "like" (about 1~2 seconds). If the user type 100 characters, the total time of the operations is about 100~200 seconds. (not a good result) I did more tests in the device, and the results are worst. Look:
SQLiteConnection cnn = openCon();
string SQL = "select cod, desc from produtcs";
SQLiteDataReader sDR;
List<MyObj> data = new List<MyObj>();
cnn.Open();// execution time: 1 second (emulator)
// execution time: 1~2 second (device)
SQLiteCommand sCommand = new SQLiteCommand(SQL, cnn);
sDR = sCommand.ExecuteReader();// execution time: 5~6 seconds (emulator)
// execution time: 18~20 seconds (device)
// alternative test: 1 seconds (emulator)
// alternative test: 6 seconds (device)
while (sDR.Read())
{
data.Add(new MyObj(Convert.ToInt32(sDR["cod"].ToString()), sDR["desc"].ToString()));
// Alternative test inserting null objects
// data.Add(new MyObj());
}// execution time: 6 seconds (emulator)
// execution time: 18 seconds (device)
// same times with alternative data
listBox1.DataSource = data;// with GRID VIEW
// execution time: 0 seconds (emulator)
// execution time: 0 seconds (device)
dataGrid1.DataSource = data;Now I'll try make it without use a List<> and insert direclty in a listBox. At the moment the best solution. I post my feedback later.
[]'s Eder Sá
The trick is to load the 12K items into an in-memory data structure, and filter on that, rather than using the Like operator against the database.
I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads
-
The trick is to load the 12K items into an in-memory data structure, and filter on that, rather than using the Like operator against the database.
I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads
Peter, I already trying do this, but i need improve the load of that 12k items. I already tried serialize and save the data in a file and load the file into the datasource, but the result are not good too. After loaded in memory my data, I use a filter with BinarySearch (modified) and works great. Thx for replys guys :)
[]'s Eder Sá
-
Bad news X| I tried use the suggested method and the result of the test in a device (HTC Touch2) is a desaster! The device spend much time running SQLs when I use "like" (about 1~2 seconds). If the user type 100 characters, the total time of the operations is about 100~200 seconds. (not a good result) I did more tests in the device, and the results are worst. Look:
SQLiteConnection cnn = openCon();
string SQL = "select cod, desc from produtcs";
SQLiteDataReader sDR;
List<MyObj> data = new List<MyObj>();
cnn.Open();// execution time: 1 second (emulator)
// execution time: 1~2 second (device)
SQLiteCommand sCommand = new SQLiteCommand(SQL, cnn);
sDR = sCommand.ExecuteReader();// execution time: 5~6 seconds (emulator)
// execution time: 18~20 seconds (device)
// alternative test: 1 seconds (emulator)
// alternative test: 6 seconds (device)
while (sDR.Read())
{
data.Add(new MyObj(Convert.ToInt32(sDR["cod"].ToString()), sDR["desc"].ToString()));
// Alternative test inserting null objects
// data.Add(new MyObj());
}// execution time: 6 seconds (emulator)
// execution time: 18 seconds (device)
// same times with alternative data
listBox1.DataSource = data;// with GRID VIEW
// execution time: 0 seconds (emulator)
// execution time: 0 seconds (device)
dataGrid1.DataSource = data;Now I'll try make it without use a List<> and insert direclty in a listBox. At the moment the best solution. I post my feedback later.
[]'s Eder Sá
Is the Sqlite-database located on your HTC? If so, try measuring the load-speed of a textfile to determine whether it can handle your required minimumspeed. I'd be using the
GetValues
method of the datareader to get an array of objects. Won't be a wowing-difference though. There should also be aSuspendLayout
method on your dataGrid control.I are Troll :suss:
-
Peter, I already trying do this, but i need improve the load of that 12k items. I already tried serialize and save the data in a file and load the file into the datasource, but the result are not good too. After loaded in memory my data, I use a filter with BinarySearch (modified) and works great. Thx for replys guys :)
[]'s Eder Sá
This is similar to an issue I faced on mobile data terminals (MDTs) a while back. Rather than storing the data in the database, we used a series of indexed files which could quickly be read and parsed at runtime. This meant that the amount of data we held in memory at any one time was minimal, and the processing was extremely rapid.
I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads
-
Hi! I started a development of a application (in Windows Mobile 6) and now i have a little problem: My datasource have 11.000~12.000 registers and when I bind it to my ListBox, this action spend 6 seconds (I think its a lot) and now I want to reduce that time. Anyone now a way to do this? Some code to exemplify my situation:
SQLiteConnection cnn = openCon();
string SQL = "select cod, desc from produtcs";
SQLiteDataReader sDR;
List<MyObj> data = new List<MyObj>();
cnn.Open();// execution time: 1 second
SQLiteCommand sCommand = new SQLiteCommand(SQL, cnn);
sDR = sCommand.ExecuteReader();// execution time: 5~6 seconds
while (sDR.Read())
{
data.Add(new MyObj(sDR["cod"].ToString(), sDR["desc"].ToString()));
}// execution time: 6 seconds
listBox1.DataSource = data;I need populate MyObj after, cuz this I use the variable "data"
class MyObj
{
public MyObj(int p1, string p2){ ... }
private int cod;
private string desc;
private string ...
private int ...// set and get methods // ...
}
[]'s Eder Sá
[]'s
Hi, Use thread to load and fill the data that will make your application responsive while the data is loading. Using thread in your application is not big deal but you have to take care about thread synchronization in your code. hope this helps. Nitheesh George http://www.simpletools.co.in
-
Hi, Use thread to load and fill the data that will make your application responsive while the data is loading. Using thread in your application is not big deal but you have to take care about thread synchronization in your code. hope this helps. Nitheesh George http://www.simpletools.co.in
This still doesn't help him lower the 6 seconds or so that he's loading the data.
I'm not a stalker, I just know things. Oh by the way, you're out of milk.
Forgive your enemies - it messes with their heads