Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

c# 4.0 - Using Task Parallel Library (C# .NET 4.0) with an external exe (ffmpeg) without conflicts -


i've been trying solve problem several days. beginner in multithreading. goal run several video encoding tasks simultaneously using ffmpeg.exe , use power of server.

i've got c# wrapper launches ffmpeg.exe process , works without threading (or ffmpeg internal threading (not available flv encoding)) looks this:

using (process process = new process()) {     process.startinfo.filename = encoderpath + "ffmpeg.exe";      process.startinfo.useshellexecute = false;     process.startinfo.redirectstandardoutput = true;     process.startinfo.redirectstandarderror = true;     process.startinfo.createnowindow = false;      string arguments = "-y -i " + filenameinput + " -f " +          getvideoformatname(format) + " -vcodec " + getvideocodecname(codec);      // (most argument setup has been omitted brevity)     arguments += " " + filenameoutput + " ";      process.startinfo.arguments = arguments;     process.startinfo.windowstyle = processwindowstyle.hidden;     process.start();      bool succes = liresortie(process);     process.waitforexit();     process.close();     return succes; } 

the code below calls wrapper. second parameter of each encode method number of threads use internal ffmpeg threading. when disable it, doesn't work.

var fm = new ffmpegwrapper();  fm.filenameinput = "test.mp4"; //videoinfo videoinfo = fm.getvideoinfo(); task[] tasks = {     task.factory.startnew(         new action(()=>{ fm.encodeto200p("test200p.mp4", 4); })),     task.factory.startnew(         new action(()=>{ fm.encodetoflash200p("test200p.flv"); })),     // ... (calls other encode methods ommitted) ...     task.factory.startnew(         new action(()=>{ fm.encodeto404p("test404p.mp4", 4); })),     task.factory.startnew(         new action(()=>{ fm.encodetoflash404p("test404p.flv"); })),     task.factory.startnew(         new action(()=>{ fm.encodeto720p("test720p.mp4", 4); })) };  task.waitall(tasks, 5000); 

you wondering why put timeout of 5000 waitall(). it's because calling thread waits indefinitely because tpl doesn't detect end tasks. ffmpeg.exe processes "stop" in middle of encoding , keep running 0% of cpu.

i think tpl , process conflicting. when status of each task tpl, remains "running" time. capture real events of ffmpeg processes tpl (or other mechanism) because, want prevent application crashing , want manage successes , failures.

i doubt problem tpl or home-grown mechanism used detect whether process ends. suspect real reason wait not indefinite classic case of thrashing due pressure on particular resource.

given description of happening , cpu appears @ low levels, pressure on io or memory. suggest profiling application using performance counters @ least (and using task manager quick on surface level) find out going on.

as commenter has suggested, makes sense eliminate tasking , determine whether one, 2 or more serial calls encode @ least work. may 1 particular call holding (e.g. encoding bug), rather resource problem.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -