该程序将影片加载到布局面板。单击这些电影后,它将在主面板中打开另一个用户控件。它显示电影等的电影海报的名称。打开电影信息用户控件之前,将显示此加载表单。 错误是
System.OutOfMemoryException in this line "panel.Controls.Add(usc)"
private void backgroundWorkerPopularMovies_DoWork(object sender, DoWorkEventArgs e)
{
popularMovieList.Clear();
WebClient wc = new WebClient();
popularMovieList = Methods.MainFormMethods.GetPopularMovieList("tr", 0, wc);
foreach (var movieUsc in popularMovieList)
{
movieUsc.MouseHover += MouseHover;
movieUsc.MouseLeave += MouseLeave;
movieUsc.MouseClick+= MouseClick;
}
}
private async void MouseClick(object sender, EventArgs eventArgs)
{
MovieUSC button = (MovieUSC) sender;
movieID = Int32.Parse(Regex.Match(button.Name, @"\d+").Value);
posterImage = button.btnMoviePoster1.Image;
LoadingUSC loadingForm = new LoadingUSC();
Methods.MainFormMethods.AddUSCToPanel(loadingForm, panelMain);
var work = Task.Factory.StartNew(Methods.MainFormMethods.GetMovieInformation);
await work;
Methods.MainFormMethods.AddUSCToPanel(getMovieInfo, panelMain);
loadingForm.Dispose();
}
public static void AddUSCToPanel(UserControl usc, Panel panel)
{
panel.Controls.Add(usc);
usc.Show();
usc.Dock = DockStyle.Fill;
usc.BringToFront();
}